home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 October: Mac OS SDK / Dev.CD Oct 00 SDK1.toast / Development Kits / Cross Platform / QuickTime 4.1.2 Windows SDK / CIncludes / OpenTransportProtocol.h < prev    next >
Encoding:
C/C++ Source or Header  |  2000-04-12  |  134.6 KB  |  4,079 lines  |  [TEXT/R*ch]

  1. /*
  2.      File:        OpenTransportProtocol.h
  3.  
  4.      Contains:    Definitions likely to be used by low-level protocol stack implementation.
  5.  
  6.      Version:    Technology:    2.5
  7.                  Release:    QuickTime 4.1
  8.  
  9.      Copyright:    (c) 1993-1999 by Apple Computer, Inc. and Mentat Inc., all rights reserved.
  10.  
  11.      Bugs?:        For bug reports, consult the following page on
  12.                  the World Wide Web:
  13.  
  14.                      http://developer.apple.com/bugreporter/
  15.  
  16. */
  17. #ifndef __OPENTRANSPORTPROTOCOL__
  18. #define __OPENTRANSPORTPROTOCOL__
  19.  
  20. #ifndef __CONDITIONALMACROS__
  21.     #include <ConditionalMacros.h>
  22. #endif
  23.  
  24.  
  25. #if CALL_NOT_IN_CARBON
  26. #ifndef __FILES__
  27.     #include <Files.h>
  28. #endif
  29.  
  30. #ifndef __CODEFRAGMENTS__
  31.     #include <CodeFragments.h>
  32. #endif
  33.  
  34. #endif  /* CALL_NOT_IN_CARBON */
  35.  
  36. #ifndef __OPENTRANSPORT__
  37.     #include <OpenTransport.h>
  38. #endif
  39.  
  40.  
  41.  
  42.  
  43. #if PRAGMA_ONCE
  44. #pragma once
  45. #endif
  46.  
  47. #ifdef __cplusplus
  48. extern "C" {
  49. #endif
  50.  
  51. #if PRAGMA_IMPORT
  52. #pragma import on
  53. #endif
  54.  
  55. #if PRAGMA_STRUCT_ALIGN
  56.     #pragma options align=mac68k
  57. #elif PRAGMA_STRUCT_PACKPUSH
  58.     #pragma pack(push, 2)
  59. #elif PRAGMA_STRUCT_PACK
  60.     #pragma pack(2)
  61. #endif
  62.  
  63. #if defined(__MWERKS__) && TARGET_CPU_68K
  64.     #pragma push
  65.     #pragma pointers_in_D0
  66. #endif
  67.  
  68. /* ***** Setup Default Compiler Variables ******/
  69.  
  70. /*
  71.    OTKERNEL is used to indicate whether the code is being built
  72.    for the kernel environment.  It defaults to 0.  If you include
  73.    "OpenTransportKernel.h" before including this file,
  74.    it will be 1 and you will only be able to see stuff available
  75.    to kernel code.
  76.    As we've included "OpenTransport.h" and it defaults this variable
  77.    to 0 if it's not already been defined, it should always be defined
  78.    by the time we get here.  So we just assert that.  Assertions in
  79.    header files!  Cool (-:
  80. */
  81.  
  82. #ifndef OTKERNEL
  83. #error OpenTransportProtocol.h expects OpenTransport.h to set up OTKERNEL.
  84. #endif  /* !defined(OTKERNEL) */
  85.  
  86. /* ***** Shared Client Memory ******/
  87. #if !OTKERNEL
  88. /*
  89.    These allocators allocate memory in the shared client pool,
  90.    which is shared between all clients and is not disposed when
  91.    a particular client goes away.  See DTS Technote ooo
  92.    "Understanding Open Transport Memory Management" for details.
  93. */
  94. EXTERN_API_C( void *)
  95. OTAllocSharedClientMem            (OTByteCount             size);
  96.  
  97. EXTERN_API_C( void )
  98. OTFreeSharedClientMem            (void *                    mem);
  99.  
  100. #endif  /* !OTKERNEL */
  101.  
  102. /* ***** UNIX Types ******/
  103. #if CALL_NOT_IN_CARBON
  104. /*
  105.    On UNIX, uid_t and gid_t are defined to be big enough
  106.    to hold a user ID and group ID respectively.  As Mac OS
  107.    has no such concepts, we just define them as UInt32 place
  108.    holders.
  109. */
  110. typedef UInt32                             uid_t;
  111. typedef UInt32                             gid_t;
  112. /* Similarly, dev_t is a UNIX type for denoting a device number.*/
  113. typedef UInt32                             dev_t;
  114. /* ***** From the Mentat "strstat.h" ******/
  115.  
  116. /* module statistics structure */
  117.  
  118. struct module_stat {
  119.     long                             ms_pcnt;                    /* count of calls to put proc */
  120.     long                             ms_scnt;                    /* count of calls to service proc */
  121.     long                             ms_ocnt;                    /* count of calls to open proc */
  122.     long                             ms_ccnt;                    /* count of calls to close proc */
  123.     long                             ms_acnt;                    /* count of calls to admin proc */
  124.     char *                            ms_xptr;                    /* pointer to private statistics */
  125.     short                             ms_xsize;                    /* length of private statistics buffer */
  126. };
  127. typedef struct module_stat                module_stat;
  128. /* ***** From the Mentat "cred.h" ******/
  129.  
  130.  
  131. struct cred {
  132.     UInt16                             cr_ref;                        /* reference count on processes using cred structures */
  133.     UInt16                             cr_ngroups;                    /* number of groups in cr_groups */
  134.     uid_t                             cr_uid;                        /* effective user id */
  135.     gid_t                             cr_gid;                        /* effective group id */
  136.     uid_t                             cr_ruid;                    /* real user id */
  137.     gid_t                             cr_rgid;                    /* real group id */
  138.     uid_t                             cr_suid;                    /* user id saved by exec */
  139.     gid_t                             cr_sgid;                    /* group id saved by exec */
  140.     gid_t                             cr_groups[1];                /* supplementary groups list */
  141. };
  142. typedef struct cred                        cred;
  143. typedef cred                             cred_t;
  144. /* Free return structure for esballoc */
  145. typedef CALLBACK_API_C( void , FreeFuncType )(char *arg);
  146.  
  147. struct free_rtn {
  148.     FreeFuncType                     free_func;                    /* Routine to call to free buffer */
  149.     char *                            free_arg;                    /* Parameter to free_func */
  150. };
  151. typedef struct free_rtn                    free_rtn;
  152.  
  153. typedef free_rtn                         frtn_t;
  154. /* data descriptor */
  155. typedef struct datab                     datab;
  156.  
  157. union datab_db_f {
  158.     datab *                            freep;
  159.     free_rtn *                        frtnp;
  160. };
  161. typedef union datab_db_f                datab_db_f;
  162.  
  163. struct datab {
  164.     datab_db_f                         db_f;
  165.     unsigned char *                    db_base;                    /* first byte of buffer */
  166.     unsigned char *                    db_lim;                        /* last byte+1 of buffer */
  167.     unsigned char                     db_ref;                        /* count of messages pointing to block*/
  168.     unsigned char                     db_type;                    /* message type */
  169.     unsigned char                     db_iswhat;                    /* message status */
  170.     unsigned char                     db_filler2;                    /* for spacing */
  171.     UInt32                             db_size;                    /* used internally */
  172.     unsigned char *                    db_msgaddr;                    /* used internally */
  173.     long                             db_filler;
  174. };
  175.  
  176.  
  177. typedef datab                             dblk_t;
  178. #define db_freep        db_f.freep
  179. #define db_frtnp        db_f.frtnp
  180.  
  181. /* message block */
  182.  
  183. struct msgb {
  184.     struct msgb *                    b_next;                        /* next message on queue */
  185.     struct msgb *                    b_prev;                        /* previous message on queue */
  186.     struct msgb *                    b_cont;                        /* next message block of message */
  187.     unsigned char *                    b_rptr;                        /* first unread data byte in buffer */
  188.     unsigned char *                    b_wptr;                        /* first unwritten data byte */
  189.     datab *                            b_datap;                    /* data block */
  190.     unsigned char                     b_band;                        /* message priority */
  191.     unsigned char                     b_pad1;
  192.     unsigned short                     b_flag;
  193. #ifdef    MSGB_XTRA
  194.  
  195.     MSGB_XTRA
  196.  
  197. #endif
  198.  
  199. };
  200. typedef struct msgb                        msgb;
  201.  
  202. typedef msgb                             mblk_t;
  203. /* mblk flags */
  204. enum {
  205.     MSGMARK                        = 0x01,                            /* last byte of message is tagged */
  206.     MSGNOLOOP                    = 0x02,                            /* don't pass message to write-side of stream */
  207.     MSGDELIM                    = 0x04,                            /* message is delimited */
  208.     MSGNOGET                    = 0x08
  209. };
  210.  
  211. /* STREAMS environments are expected to define these constants in a public header file.*/
  212.  
  213. enum {
  214.     STRCTLSZ                    = 256,                            /* Maximum Control buffer size for messages    */
  215.     STRMSGSZ                    = 8192                            /* Maximum # data bytes for messages        */
  216. };
  217.  
  218. /* Message types */
  219. enum {
  220.     QNORM                        = 0,
  221.     M_DATA                        = 0,                            /* Ordinary data */
  222.     M_PROTO                        = 1,                            /* Internal control info and data */
  223.     M_BREAK                        = 0x08,                            /* Request a driver to send a break */
  224.     M_PASSFP                    = 0x09,                            /* Used to pass a file pointer */
  225.     M_SIG                        = 0x0B,                            /* Requests a signal to be sent */
  226.     M_DELAY                        = 0x0C,                            /* Request a real-time delay */
  227.     M_CTL                        = 0x0D,                            /* For inter-module communication */
  228.     M_IOCTL                        = 0x0E,                            /* Used internally for I_STR requests */
  229.     M_SETOPTS                    = 0x10,                            /* Alters characteristics of Stream head */
  230.     M_RSE                        = 0x11                            /* Reserved for internal use */
  231. };
  232.  
  233. /* MPS private type */
  234. enum {
  235.     M_MI                        = 0x40,
  236.     M_MI_READ_RESET                = 1,
  237.     M_MI_READ_SEEK                = 2,
  238.     M_MI_READ_END                = 4
  239. };
  240.  
  241. /* Priority messages types */
  242. enum {
  243.     QPCTL                        = 0x80,
  244.     M_IOCACK                    = 0x81,                            /* Positive ack of previous M_IOCTL */
  245.     M_IOCNAK                    = 0x82,                            /* Previous M_IOCTL failed */
  246.     M_PCPROTO                    = 0x83,                            /* Same as M_PROTO except for priority */
  247.     M_PCSIG                        = 0x84,                            /* Priority signal */
  248.     M_FLUSH                        = 0x86,                            /* Requests modules to flush queues */
  249.     M_STOP                        = 0x87,                            /* Request drivers to stop output */
  250.     M_START                        = 0x88,                            /* Request drivers to start output */
  251.     M_HANGUP                    = 0x89,                            /* Driver can no longer produce data */
  252.     M_ERROR                        = 0x8A,                            /* Reports downstream error condition */
  253.     M_READ                        = 0x8B,                            /* Reports client read at Stream head */
  254.     M_COPYIN                    = 0x8C,                            /* Requests the Stream to copy data in for a module */
  255.     M_COPYOUT                    = 0x8D,                            /* Requests the Stream to copy data out for a module */
  256.     M_IOCDATA                    = 0x8E,                            /* Status from M_COPYIN/M_COPYOUT message */
  257.     M_PCRSE                        = 0x90,                            /* Reserved for internal use */
  258.     M_STOPI                        = 0x91,                            /* Request drivers to stop input */
  259.     M_STARTI                    = 0x92,                            /* Request drivers to start input */
  260.     M_HPDATA                    = 0x93                            /* MPS-private type; high priority data */
  261. };
  262.  
  263. /* Defines for flush messages */
  264. enum {
  265.     FLUSHALL                    = 1,
  266.     FLUSHDATA                    = 0
  267. };
  268.  
  269.  
  270. enum {
  271.     NOERROR                        = -1                            /* used in M_ERROR messages */
  272. };
  273.  
  274. typedef struct sth_s sth_s;
  275. typedef struct sqh_s sqh_s;
  276. typedef struct q_xtra q_xtra;
  277. #if OTKERNEL
  278. /*
  279.    module_info is aligned differently on 68K than
  280.    on PowerPC.  Yucky.  I can't defined a conditionalised
  281.    pad field because a) you can't conditionalise specific
  282.    fields in the interface definition language used to
  283.    create Universal Interfaces, and b) lots of code 
  284.    assigns C structured constants to global variables
  285.    of this type, and these assignments break if you
  286.    add an extra field to the type.  Instead, I
  287.    set the alignment appropriately before defining the 
  288.    structure.  The problem with doing that is that
  289.    the interface definition language doesn't allow
  290.    my to set the alignment in the middle of a file,
  291.    so I have to do this via "pass throughs".  This
  292.    works fine for the well known languages (C, Pascal),
  293.    but may cause problems for other languages (Java,
  294.    Asm).
  295. */
  296. #if TARGET_CPU_PPC
  297.  #pragma options align=power
  298. #endif
  299.  
  300. struct module_info {
  301.     unsigned short                     mi_idnum;                    /* module ID number */
  302.     char *                            mi_idname;                    /* module name */
  303.     long                             mi_minpsz;                    /* min pkt size, for developer use */
  304.     long                             mi_maxpsz;                    /* max pkt size, for developer use */
  305.     unsigned long                     mi_hiwat;                    /* hi-water mark, for flow control */
  306.     unsigned long                     mi_lowat;                    /* lo-water mark, for flow control */
  307. };
  308. typedef struct module_info                module_info;
  309. typedef module_info *                    module_infoPtr;
  310. #if TARGET_CPU_PPC
  311.  #pragma options align=reset
  312. #endif
  313.  
  314.  
  315. typedef struct queue                     queue;
  316. typedef CALLBACK_API_C( OTInt32 , admin_t )(void );
  317. typedef CALLBACK_API_C( void , bufcall_t )(long size);
  318. typedef CALLBACK_API_C( void , bufcallp_t )(long size);
  319. typedef CALLBACK_API_C( OTInt32 , closep_t )(queue *q, OTInt32 foo, cred_t *cred);
  320. typedef CALLBACK_API_C( OTInt32 , old_closep_t )(queue *q);
  321. typedef CALLBACK_API_C( OTInt32 , openp_t )(queue *q, dev_t *dev, OTInt32 foo, OTInt32 bar, cred_t *cred);
  322. typedef CALLBACK_API_C( OTInt32 , openOld_t )(queue *q, dev_t dev, OTInt32 foo, OTInt32 bar);
  323. typedef CALLBACK_API_C( OTInt32 , old_openp_t )(queue *q, dev_t dev, OTInt32 foo, OTInt32 bar);
  324. typedef CALLBACK_API_C( OTInt32 , closeOld_t )(queue *q);
  325. typedef CALLBACK_API_C( OTInt32 , putp_t )(queue *q, msgb *mp);
  326. typedef CALLBACK_API_C( OTInt32 , srvp_t )(queue *q);
  327.  
  328. struct qinit {
  329.     putp_t                             qi_putp;                    /* put procedure */
  330.     srvp_t                             qi_srvp;                    /* service procedure */
  331.     openp_t                         qi_qopen;                    /* called on each open or a push */
  332.     closep_t                         qi_qclose;                    /* called on last close or a pop */
  333.     admin_t                         qi_qadmin;                    /* reserved for future use */
  334.     module_info *                    qi_minfo;                    /* information structure */
  335.     module_stat *                    qi_mstat;                    /* statistics structure - optional */
  336. };
  337. typedef struct qinit                    qinit;
  338. /* defines module or driver */
  339.  
  340. struct streamtab {
  341.     qinit *                            st_rdinit;                    /* defines read QUEUE */
  342.     qinit *                            st_wrinit;                    /* defines write QUEUE */
  343.     qinit *                            st_muxrinit;                /* for multiplexing drivers only */
  344.     qinit *                            st_muxwinit;                /* ditto */
  345. };
  346. typedef struct streamtab                streamtab;
  347.  
  348. struct qband {
  349.     struct qband *                    qb_next;                    /* next band for this queue */
  350.     unsigned long                     qb_count;                    /* weighted count of characters in this band */
  351.     msgb *                            qb_first;                    /* head of message queue */
  352.     msgb *                            qb_last;                    /* tail of message queue */
  353.     unsigned long                     qb_hiwat;                    /* high water mark */
  354.     unsigned long                     qb_lowat;                    /* low water mark */
  355.     unsigned short                     qb_flag;                    /* ooo.state */
  356.     short                             qb_pad1;                    /* ooo reserved */
  357. };
  358. typedef struct qband                    qband;
  359. typedef qband                             qband_t;
  360.  
  361. union queue_q_u {
  362.     queue *                            q_u_link;                    /* link to scheduling queue */
  363.     sqh_s *                            q_u_sqh_parent;
  364. };
  365. typedef union queue_q_u                    queue_q_u;
  366.  
  367. struct queue {
  368.     qinit *                            q_qinfo;                    /* procedures and limits for queue */
  369.     msgb *                            q_first;                    /* head of message queue */
  370.     msgb *                            q_last;                        /* tail of message queue */
  371.     struct queue *                    q_next;                        /* next queue in Stream */
  372.     queue_q_u                         q_u;
  373.     char *                            q_ptr;                        /* to private data structure */
  374.     unsigned long                     q_count;                    /* weighted count of characters on q */
  375.     long                             q_minpsz;                    /* min packet size accepted */
  376.     long                             q_maxpsz;                    /* max packet size accepted */
  377.     unsigned long                     q_hiwat;                    /* high water mark, for flow control */
  378.     unsigned long                     q_lowat;                    /* low water mark */
  379.     qband *                            q_bandp;                    /* band information */
  380.     unsigned short                     q_flag;                        /* ooo queue state */
  381.     unsigned char                     q_nband;                    /* ooo number of bands */
  382.     unsigned char                     q_pad1[1];                    /* ooo reserved */
  383.     q_xtra *                        q_osx;                        /* Pointer to OS-dependent extra stuff */
  384.     struct queue *                    q_ffcp;                        /* Forward flow control pointer */
  385.     struct queue *                    q_bfcp;                        /* Backward flow control pointer */
  386. };
  387.  
  388.  
  389. typedef queue *                            queuePtr;
  390. typedef queue                             queue_t;
  391. #define q_link            q_u.q_u_link
  392. #define q_sqh_parent    q_u.q_u_sqh_parent
  393.  
  394. /* queue_t flag defines */
  395. enum {
  396.     QREADR                        = 0x01,                            /* This queue is a read queue */
  397.     QNOENB                        = 0x02,                            /* Don't enable in putq */
  398.     QFULL                        = 0x04,                            /* The queue is full */
  399.     QWANTR                        = 0x08,                            /* The queue should be scheduled in the next putq */
  400.     QWANTW                        = 0x10,                            /* The stream should be back enabled when this queue drains */
  401.     QUSE                        = 0x20,                            /* The queue is allocated and ready for use */
  402.     QENAB                        = 0x40,                            /* The queue is scheduled (on the run queue) */
  403.     QBACK                        = 0x80,                            /* The queue has been back enabled */
  404.     QOLD                        = 0x0100,                        /* Module supports old style opens and closes */
  405.     QHLIST                        = 0x0200,                        /* The Stream head is doing something with this queue (Not supported by MPS) */
  406.     QWELDED                        = 0x0400,                        /* Mentat flag for welded queues */
  407.     QUNWELDING                    = 0x0800,                        /* Queue is scheduled to be unwelded */
  408.     QPROTECTED                    = 0x1000,                        /* Mentat flag for unsafe q access */
  409.     QEXCOPENCLOSE                = 0x2000                        /* Queue wants exclusive open/close calls */
  410. };
  411.  
  412. /* qband_t flag defines */
  413. enum {
  414.     QB_FULL                        = 0x01,                            /* The band is full */
  415.     QB_WANTW                    = 0x02,                            /* The stream should be back enabled when this band/queue drains */
  416.     QB_BACK                        = 0x04                            /* The queue has been back enabled */
  417. };
  418.  
  419. #else
  420. /*
  421.    Client code views a queue_t as a simple cookie.
  422.    The real definition lives above and is only available
  423.    to kernel code.
  424. */
  425.  
  426. struct queue {
  427.     UInt32                             dummy;
  428. };
  429. typedef struct queue                    queue;
  430. typedef SInt32                             queue_t;
  431. #endif  /* OTKERNEL */
  432.  
  433. /* structure contained in M_COPYIN/M_COPYOUT messages */
  434.  
  435. typedef unsigned char *                    caddr_t;
  436.  
  437. struct copyreq {
  438.     SInt32                             cq_cmd;                        /* ioctl command (from ioc_cmd) */
  439.     cred *                            cq_cr;                        /* pointer to full credentials */
  440.     UInt32                             cq_id;                        /* ioctl id (from ioc_id) */
  441.     caddr_t                         cq_addr;                    /* address to copy data to/from */
  442.     UInt32                             cq_size;                    /* number of bytes to copy */
  443.     SInt32                             cq_flag;                    /* state */
  444.     mblk_t *                        cq_private;                    /* private state information */
  445.     long                             cq_filler[4];
  446. };
  447. typedef struct copyreq                    copyreq;
  448. #define cq_uid    cq_cr->cr_uid
  449. #define cq_gid    cq_cr->cr_gid
  450.  
  451.  
  452. /* copyreq defines */
  453. enum {
  454.     STRCANON                    = 0x01,                            /* b_cont data block contains canonical format specifier */
  455.     RECOPY                        = 0x02                            /* perform I_STR copyin again this time using canonical format specifier */
  456. };
  457.  
  458. /* structure contained in M_IOCDATA message block */
  459.  
  460. struct copyresp {
  461.     SInt32                             cp_cmd;                        /* ioctl command (from ioc_cmd) */
  462.     cred *                            cp_cr;                        /* pointer to full credentials */
  463.     UInt32                             cp_id;                        /* ioctl id (from ioc_id) */
  464.     caddr_t                         cp_rval;                    /* status of request; 0 for success; error value for failure */
  465.     UInt32                             cp_pad1;
  466.     SInt32                             cp_pad2;
  467.     mblk_t *                        cp_private;                    /* private state information */
  468.     long                             cp_filler[4];
  469. };
  470. typedef struct copyresp                    copyresp;
  471. #define cp_uid    cp_cr->cr_uid
  472. #define cp_gid    cp_cr->cr_gid
  473.  
  474. /* structure contained in an M_IOCTL message block */
  475.  
  476. struct iocblk {
  477.     SInt32                             ioc_cmd;                    /* ioctl command type */
  478.     cred *                            ioc_cr;                        /* pointer to full credentials */
  479.     UInt32                             ioc_id;                        /* ioctl id */
  480.     UInt32                             ioc_count;                    /* count of bytes in data field */
  481.     SInt32                             ioc_error;                    /* error code */
  482.     SInt32                             ioc_rval;                    /* return value */
  483.     long                             ioc_filler[4];
  484. };
  485. typedef struct iocblk                    iocblk;
  486. #define ioc_uid ioc_cr->cr_uid
  487. #define ioc_gid ioc_cr->cr_gid
  488.  
  489.  
  490.  
  491. enum {
  492.     TRANSPARENT                    = 0xFFFFFFFF
  493. };
  494.  
  495. /* Used in M_IOCTL mblks to muxes (ioc_cmd I_LINK) */
  496.  
  497. struct linkblk {
  498.     queue *                            l_qtop;                        /* lowest level write queue of upper stream */
  499.     queue *                            l_qbot;                        /* highest level write queue of lower stream */
  500.     SInt32                             l_index;                    /* system-unique index for lower stream */
  501.     long                             l_pad[5];
  502. };
  503. typedef struct linkblk                    linkblk;
  504. /* structure contained in an M_PASSFP message block */
  505.  
  506. struct strpfp {
  507.     unsigned long                     pass_file_cookie;            /* file 'pointer' */
  508.     unsigned short                     pass_uid;                    /* user id of sending stream */
  509.     unsigned short                     pass_gid;
  510.     sth_s *                            pass_sth;                    /* Stream head pointer of passed stream */
  511. };
  512. typedef struct strpfp                    strpfp;
  513. /* structure contained in an M_SETOPTS message block */
  514.  
  515. struct stroptions {
  516.     unsigned long                     so_flags;                    /* options to set */
  517.     short                             so_readopt;                    /* read option */
  518.     unsigned short                     so_wroff;                    /* write offset */
  519.     long                             so_minpsz;                    /* minimum read packet size */
  520.     long                             so_maxpsz;                    /* maximum read packet size */
  521.     unsigned long                     so_hiwat;                    /* read queue high-water mark */
  522.     unsigned long                     so_lowat;                    /* read queue low-water mark */
  523.     unsigned char                     so_band;                    /* band for water marks */
  524.     unsigned char                     so_filler[3];                /* added for alignment */
  525.     unsigned long                     so_poll_set;                /* poll events to set */
  526.     unsigned long                     so_poll_clr;                /* poll events to clear */
  527. };
  528. typedef struct stroptions                stroptions;
  529. /* definitions for so_flags field */
  530. enum {
  531.     SO_ALL                        = 0x7FFF,                        /* Update all options */
  532.     SO_READOPT                    = 0x0001,                        /* Set the read mode */
  533.     SO_WROFF                    = 0x0002,                        /* Insert an offset in write M_DATA mblks */
  534.     SO_MINPSZ                    = 0x0004,                        /* Change the min packet size on sth rq */
  535.     SO_MAXPSZ                    = 0x0008,                        /* Change the max packet size on sth rq */
  536.     SO_HIWAT                    = 0x0010,                        /* Change the high water mark on sth rq */
  537.     SO_LOWAT                    = 0x0020,                        /* Change the low water mark */
  538.     SO_MREADON                    = 0x0040,                        /* Request M_READ messages */
  539.     SO_MREADOFF                    = 0x0080,                        /* Don't gen M_READ messages */
  540.     SO_NDELON                    = 0x0100,                        /* old TTY semantics for O_NDELAY reads and writes */
  541.     SO_NDELOFF                    = 0x0200,                        /* STREAMS semantics for O_NDELAY reads and writes */
  542.     SO_ISTTY                    = 0x0400,                        /* Become a controlling tty */
  543.     SO_ISNTTY                    = 0x0800,                        /* No longer a controlling tty */
  544.     SO_TOSTOP                    = 0x1000,                        /* Stop on background writes */
  545.     SO_TONSTOP                    = 0x2000,                        /* Don't stop on background writes */
  546.     SO_BAND                        = 0x4000,                        /* Water marks are for a band */
  547.     SO_POLL_SET                    = 0x8000,                        /* Set events to poll */
  548.     SO_POLL_CLR                    = 0x00010000                    /* Clear events to poll */
  549. };
  550.  
  551. /* Buffer Allocation Priority */
  552. enum {
  553.     BPRI_LO                        = 1,
  554.     BPRI_MED                    = 2,
  555.     BPRI_HI                        = 3
  556. };
  557.  
  558. enum {
  559.     INFPSZ                        = -1
  560. };
  561.  
  562.  
  563. /** Test whether message is a data message */
  564. #define datamsg(type)    ((type) == M_DATA || (type) == M_PROTO || (type) == M_PCPROTO  ||  (type) == M_DELAY)
  565.  
  566. enum {
  567.     CLONEOPEN                    = 0x02,
  568.     MODOPEN                        = 0x01,
  569.     OPENFAIL                    = -1
  570. };
  571.  
  572.  
  573. /* Enumeration values for strqget and strqset */
  574.  
  575. typedef SInt32 qfields;
  576. enum {
  577.     QHIWAT                        = 0,
  578.     QLOWAT                        = 1,
  579.     QMAXPSZ                        = 2,
  580.     QMINPSZ                        = 3,
  581.     QCOUNT                        = 4,
  582.     QFIRST                        = 5,
  583.     QLAST                        = 6,
  584.     QFLAG                        = 7,
  585.     QBAD                        = 8
  586. };
  587.  
  588.  
  589. typedef qfields                         qfields_t;
  590. #endif  /* CALL_NOT_IN_CARBON */
  591.  
  592. /* ***** From the Mentat "stropts.h" ******/
  593.  
  594.  
  595. enum {
  596.     I_NREAD                        = ((MIOC_STREAMIO << 8) | 1),    /* return the number of bytes in 1st msg */
  597.     I_PUSH                        = ((MIOC_STREAMIO << 8) | 2),    /* push module just below stream head */
  598.     I_POP                        = ((MIOC_STREAMIO << 8) | 3),    /* pop module below stream head */
  599.     I_LOOK                        = ((MIOC_STREAMIO << 8) | 4),    /* retrieve name of first stream module */
  600.     I_FLUSH                        = ((MIOC_STREAMIO << 8) | 5),    /* flush all input and/or output queues */
  601.     I_SRDOPT                    = ((MIOC_STREAMIO << 8) | 6),    /* set the read mode */
  602.     I_GRDOPT                    = ((MIOC_STREAMIO << 8) | 7),    /* get the current read mode */
  603.     I_STR                        = ((MIOC_STREAMIO << 8) | 8),    /* create an internal ioctl message            */
  604.     I_SETSIG                    = ((MIOC_STREAMIO << 8) | 9),    /* request SIGPOLL signal on events */
  605.     I_GETSIG                    = ((MIOC_STREAMIO << 8) | 10),    /* query the registered events */
  606.     I_FIND                        = ((MIOC_STREAMIO << 8) | 11),    /* check for module in stream                */
  607.     I_LINK                        = ((MIOC_STREAMIO << 8) | 12),    /* connect stream under mux fd */
  608.     I_UNLINK                    = ((MIOC_STREAMIO << 8) | 13),    /* disconnect two streams */
  609.     I_PEEK                        = ((MIOC_STREAMIO << 8) | 15),    /* peek at data on read queue */
  610.     I_FDINSERT                    = ((MIOC_STREAMIO << 8) | 16),    /* create a message and send downstream */
  611.     I_SENDFD                    = ((MIOC_STREAMIO << 8) | 17),    /* send an fd to a connected pipe stream */
  612.     I_RECVFD                    = ((MIOC_STREAMIO << 8) | 18),    /* retrieve a file descriptor */
  613.     I_FLUSHBAND                    = ((MIOC_STREAMIO << 8) | 19),    /* flush a particular input and/or output band */
  614.     I_SWROPT                    = ((MIOC_STREAMIO << 8) | 20),    /* set the write mode */
  615.     I_GWROPT                    = ((MIOC_STREAMIO << 8) | 21),    /* get the current write mode */
  616.     I_LIST                        = ((MIOC_STREAMIO << 8) | 22),    /* get a list of all modules on a stream    */
  617.     I_ATMARK                    = ((MIOC_STREAMIO << 8) | 23),    /* check to see if the next message is "marked" */
  618.     I_CKBAND                    = ((MIOC_STREAMIO << 8) | 24),    /* check for a message of a particular band */
  619.     I_GETBAND                    = ((MIOC_STREAMIO << 8) | 25),    /* get the band of the next message to be read */
  620.     I_CANPUT                    = ((MIOC_STREAMIO << 8) | 26),    /* check to see if a message may be passed on a stream */
  621.     I_SETCLTIME                    = ((MIOC_STREAMIO << 8) | 27),    /* set the close timeout wait */
  622.     I_GETCLTIME                    = ((MIOC_STREAMIO << 8) | 28),    /* get the current close timeout wait */
  623.     I_PLINK                        = ((MIOC_STREAMIO << 8) | 29),    /* permanently connect a stream under a mux */
  624.     I_PUNLINK                    = ((MIOC_STREAMIO << 8) | 30),    /* disconnect a permanent link */
  625.     I_GETMSG                    = ((MIOC_STREAMIO << 8) | 40),    /* getmsg() system call */
  626.     I_PUTMSG                    = ((MIOC_STREAMIO << 8) | 41),    /* putmsg() system call */
  627.     I_POLL                        = ((MIOC_STREAMIO << 8) | 42),    /* poll() system call */
  628.     I_SETDELAY                    = ((MIOC_STREAMIO << 8) | 43),    /* set blocking status */
  629.     I_GETDELAY                    = ((MIOC_STREAMIO << 8) | 44),    /* get blocking status */
  630.     I_RUN_QUEUES                = ((MIOC_STREAMIO << 8) | 45),    /* sacrifice for the greater good */
  631.     I_GETPMSG                    = ((MIOC_STREAMIO << 8) | 46),    /* getpmsg() system call */
  632.     I_PUTPMSG                    = ((MIOC_STREAMIO << 8) | 47),    /* putpmsg() system call */
  633.     I_AUTOPUSH                    = ((MIOC_STREAMIO << 8) | 48),    /* for systems that cannot do the autopush in open */
  634.     I_PIPE                        = ((MIOC_STREAMIO << 8) | 49),    /* for pipe library call */
  635.     I_HEAP_REPORT                = ((MIOC_STREAMIO << 8) | 50),    /* get heap statistics */
  636.     I_FIFO                        = ((MIOC_STREAMIO << 8) | 51)    /* for fifo library call */
  637. };
  638.  
  639. /* priority message request on putmsg() or strpeek */
  640. enum {
  641.     RS_HIPRI                    = 0x01
  642. };
  643.  
  644. /* flags for getpmsg and putpmsg */
  645. enum {
  646.     MSG_HIPRI                    = 0x01,
  647.     MSG_BAND                    = 0x02,                            /* Retrieve a message from a particular band */
  648.     MSG_ANY                        = 0x04                            /* Retrieve a message from any band */
  649. };
  650.  
  651. /* return values from getmsg(), 0 indicates all ok */
  652. enum {
  653.     MORECTL                        = 0x01,                            /* more control info available */
  654.     MOREDATA                    = 0x02                            /* more data available */
  655. };
  656.  
  657.  
  658. enum {
  659.     FMNAMESZ                    = 31                            /* maximum length of a module or device name */
  660. };
  661.  
  662.  
  663. /* Infinite poll wait time */
  664. enum {
  665.     INFTIM                        = 0xFFFFFFFF
  666. };
  667.  
  668. /* flush requests */
  669. enum {
  670.     FLUSHR                        = 0x01,                            /* Flush the read queue */
  671.     FLUSHW                        = 0x02,                            /* Flush the write queue */
  672.     FLUSHRW                        = (FLUSHW | FLUSHR)                /* Flush both */
  673. };
  674.  
  675. enum {
  676.     FLUSHBAND                    = 0x40                            /* Flush a particular band */
  677. };
  678.  
  679. /* I_FLUSHBAND */
  680.  
  681. struct bandinfo {
  682.     unsigned char                     bi_pri;                        /* Band to flush */
  683.     char                             pad1;
  684.     SInt32                             bi_flag;                    /* One of the above flush requests */
  685. };
  686. typedef struct bandinfo                    bandinfo;
  687. /* flags for I_ATMARK */
  688. enum {
  689.     ANYMARK                        = 0x01,                            /* Check if message is marked */
  690.     LASTMARK                    = 0x02                            /* Check if this is the only message marked */
  691. };
  692.  
  693. /* signal event masks */
  694. enum {
  695.     S_INPUT                        = 0x01,                            /* A non-M_PCPROTO message has arrived */
  696.     S_HIPRI                        = 0x02,                            /* A priority (M_PCPROTO) message is available */
  697.     S_OUTPUT                    = 0x04,                            /* The write queue is no longer full */
  698.     S_MSG                        = 0x08,                            /* A signal message has reached the front of read queue */
  699.     S_RDNORM                    = 0x10,                            /* A non-priority message is available */
  700.     S_RDBAND                    = 0x20,                            /* A banded messsage is available */
  701.     S_WRNORM                    = 0x40,                            /* Same as S_OUTPUT */
  702.     S_WRBAND                    = 0x80,                            /* A priority band exists and is writable */
  703.     S_ERROR                        = 0x0100,                        /* Error message has arrived */
  704.     S_HANGUP                    = 0x0200,                        /* Hangup message has arrived */
  705.     S_BANDURG                    = 0x0400                        /* Use SIGURG instead of SIGPOLL on S_RDBAND signals */
  706. };
  707.  
  708. /* read mode bits for I_S|GRDOPT; choose one of the following */
  709. enum {
  710.     RNORM                        = 0x01,                            /* byte-stream mode, default */
  711.     RMSGD                        = 0x02,                            /* message-discard mode */
  712.     RMSGN                        = 0x04,                            /* message-nondiscard mode */
  713.     RFILL                        = 0x08                            /* fill read buffer mode (PSE private) */
  714. };
  715.  
  716. /* More read modes, these are bitwise or'ed with the modes above */
  717. enum {
  718.     RPROTNORM                    = 0x10,                            /* Normal handling of M_PROTO/M_PCPROTO messages, default */
  719.     RPROTDIS                    = 0x20,                            /* Discard M_PROTO/M_PCPROTO message blocks */
  720.     RPROTDAT                    = 0x40                            /* Convert M_PROTO/M_PCPROTO message blocks into M_DATA */
  721. };
  722.  
  723. /* write modes for I_S|GWROPT */
  724. enum {
  725.     SNDZERO                        = 0x01                            /* Send a zero-length message downstream on a write of zero bytes */
  726. };
  727.  
  728. enum {
  729.     MUXID_ALL                    = -1                            /* Unlink all lower streams for I_UNLINK and I_PUNLINK */
  730. };
  731.  
  732. /*
  733.    strbuf is moved to "OpenTransport.h" because that header file
  734.    exports provider routines that take it as a parameter.
  735. */
  736.  
  737. /* structure of ioctl data on I_FDINSERT */
  738.  
  739. struct strfdinsert {
  740.     strbuf                             ctlbuf;
  741.     strbuf                             databuf;
  742.     long                             flags;                        /* type of message, 0 or RS_HIPRI */
  743.     long                             fildes;                        /* fd of other stream (FDCELL) */
  744.     SInt32                             offset;                        /* where to put other stream read qp */
  745. };
  746. typedef struct strfdinsert                strfdinsert;
  747. /* I_LIST structures */
  748.  
  749. struct str_mlist {
  750.     char                             l_name[32];
  751. };
  752. typedef struct str_mlist                str_mlist;
  753.  
  754. struct str_list {
  755.     SInt32                             sl_nmods;                    /* number of modules in sl_modlist array */
  756.     str_mlist *                        sl_modlist;
  757. };
  758. typedef struct str_list                    str_list;
  759. /* I_PEEK structure */
  760.  
  761. struct strpeek {
  762.     strbuf                             ctlbuf;
  763.     strbuf                             databuf;
  764.     long                             flags;                        /* if RS_HIPRI, get priority messages only */
  765. };
  766. typedef struct strpeek                    strpeek;
  767. /* structure for getpmsg and putpmsg */
  768.  
  769. struct strpmsg {
  770.     strbuf                             ctlbuf;
  771.     strbuf                             databuf;
  772.     SInt32                             band;
  773.     long                             flags;
  774. };
  775. typedef struct strpmsg                    strpmsg;
  776. /* structure of ioctl data on I_RECVFD */
  777.  
  778. struct strrecvfd {
  779.     long                             fd;                            /* new file descriptor (FDCELL) */
  780.     unsigned short                     uid;                        /* user id of sending stream */
  781.     unsigned short                     gid;
  782.     char                             fill[8];
  783. };
  784. typedef struct strrecvfd                strrecvfd;
  785. /* structure of ioctl data on I_STR */
  786.  
  787. struct strioctl {
  788.     SInt32                             ic_cmd;                        /* downstream command */
  789.     SInt32                             ic_timout;                    /* ACK/NAK timeout */
  790.     SInt32                             ic_len;                        /* length of data arg */
  791.     char *                            ic_dp;                        /* ptr to data arg */
  792. };
  793. typedef struct strioctl                    strioctl;
  794. /* ***** From the Mentat "strlog.h" ******/
  795.  
  796.  
  797. struct log_ctl {
  798.     short                             mid;
  799.     short                             sid;
  800.     char                             level;
  801.     char                             pad1;
  802.     short                             flags;
  803.     long                             ltime;
  804.     long                             ttime;
  805.     SInt32                             seq_no;
  806. };
  807. typedef struct log_ctl                    log_ctl;
  808. enum {
  809.     SL_FATAL                    = 0x01,                            /* Fatal error */
  810.     SL_NOTIFY                    = 0x02,                            /* Notify the system administrator */
  811.     SL_ERROR                    = 0x04,                            /* Pass message to error logger */
  812.     SL_TRACE                    = 0x08,                            /* Pass message to tracer */
  813.     SL_CONSOLE                    = 0x00,                            /* Console messages are disabled */
  814.     SL_WARN                        = 0x20,                            /* Warning */
  815.     SL_NOTE                        = 0x40                            /* Notice this message */
  816. };
  817.  
  818.  
  819. struct trace_ids {
  820.     short                             ti_mid;
  821.     short                             ti_sid;
  822.     char                             ti_level;
  823. };
  824. typedef struct trace_ids                trace_ids;
  825. enum {
  826.     I_TRCLOG                    = ((MIOC_STRLOG << 8) | 1),
  827.     I_ERRLOG                    = ((MIOC_STRLOG << 8) | 2)
  828. };
  829.  
  830. enum {
  831.     LOGMSGSZ                    = 128
  832. };
  833.  
  834. /* ***** From the Mentat "tihdr.h" ******/
  835.  
  836. #if CALL_NOT_IN_CARBON
  837.  
  838. /* TPI Primitives*/
  839.  
  840.  
  841.  
  842. enum {
  843.     T_BIND_REQ = 101,
  844.     T_CONN_REQ = 102,            /* connection request */
  845.     T_CONN_RES = 103,            /* respond to connection indication */
  846.     T_DATA_REQ = 104,
  847.     T_DISCON_REQ = 105,
  848.     T_EXDATA_REQ = 106,
  849.     T_INFO_REQ = 107,
  850.     T_OPTMGMT_REQ = 108,
  851.     T_ORDREL_REQ = 109,
  852.     T_UNBIND_REQ = 110,
  853.     T_UNITDATA_REQ = 111,
  854.     T_ADDR_REQ = 112,            /* Get address request                */
  855.     T_UREQUEST_REQ = 113,        /* UnitRequest (transaction) req    */
  856.     T_REQUEST_REQ = 114,        /* Request (CO transaction) req        */
  857.     T_UREPLY_REQ = 115,            /* UnitRequest (transaction) req    */
  858.     T_REPLY_REQ = 116,            /* REPLY (CO transaction) req        */
  859.     T_CANCELREQUEST_REQ = 117,    /* Cancel outgoing request            */
  860.     T_CANCELREPLY_REQ = 118,    /* Cancel incoming request            */
  861.     T_REGNAME_REQ = 119,        /* Request name registration        */
  862.     T_DELNAME_REQ = 120,        /* Request delete name registration */
  863.     T_LKUPNAME_REQ = 121,        /* Request name lookup              */
  864.  
  865.     T_BIND_ACK = 122,
  866.     T_CONN_CON = 123,            /* connection confirmation             */
  867.     T_CONN_IND = 124,            /* incoming connection indication     */
  868.     T_DATA_IND = 125,
  869.     T_DISCON_IND = 126,
  870.     T_ERROR_ACK = 127,
  871.     T_EXDATA_IND = 128,
  872.     T_INFO_ACK = 129,
  873.     T_OK_ACK = 130,
  874.     T_OPTMGMT_ACK = 131,
  875.     T_ORDREL_IND = 132,
  876.     T_UNITDATA_IND = 133,
  877.     T_UDERROR_IND = 134,
  878.     T_ADDR_ACK = 135,            /* Get address ack                    */
  879.     T_UREQUEST_IND = 136,        /* UnitRequest (transaction) ind    */
  880.     T_REQUEST_IND = 137,        /* Request (CO transaction) ind     */
  881.     T_UREPLY_IND = 138,            /* Incoming unit reply                */
  882.     T_REPLY_IND = 139,            /* Incoming reply                    */
  883.     T_UREPLY_ACK = 140,            /* outgoing Unit Reply is complete    */
  884.     T_REPLY_ACK = 141,            /* outgoing Reply is complete        */
  885.     T_RESOLVEADDR_REQ = 142,
  886.     T_RESOLVEADDR_ACK = 143,
  887.  
  888.     T_LKUPNAME_CON = 146,        /* Results of name lookup           */
  889.     T_LKUPNAME_RES = 147,        /* Partial results of name lookup    */
  890.     T_REGNAME_ACK = 148,        /* Request name registration        */
  891.     T_SEQUENCED_ACK = 149,        /* Sequenced version of OK or ERROR ACK */
  892.  
  893.     T_EVENT_IND = 160            /* Miscellaneous event Indication        */
  894. };
  895.  
  896. /* State values */
  897. enum {
  898.     TS_UNBND                    = 1,
  899.     TS_WACK_BREQ                = 2,
  900.     TS_WACK_UREQ                = 3,
  901.     TS_IDLE                        = 4,
  902.     TS_WACK_OPTREQ                = 5,
  903.     TS_WACK_CREQ                = 6,
  904.     TS_WCON_CREQ                = 7,
  905.     TS_WRES_CIND                = 8,
  906.     TS_WACK_CRES                = 9,
  907.     TS_DATA_XFER                = 10,
  908.     TS_WIND_ORDREL                = 11,
  909.     TS_WREQ_ORDREL                = 12,
  910.     TS_WACK_DREQ6                = 13,
  911.     TS_WACK_DREQ7                = 14,
  912.     TS_WACK_DREQ9                = 15,
  913.     TS_WACK_DREQ10                = 16,
  914.     TS_WACK_DREQ11                = 17,
  915.     TS_WACK_ORDREL                = 18,
  916.     TS_NOSTATES                    = 19,
  917.     TS_BAD_STATE                = 19
  918. };
  919.  
  920. /* Transport events */
  921. enum {
  922.     TE_OPENED                    = 1,
  923.     TE_BIND                        = 2,
  924.     TE_OPTMGMT                    = 3,
  925.     TE_UNBIND                    = 4,
  926.     TE_CLOSED                    = 5,
  927.     TE_CONNECT1                    = 6,
  928.     TE_CONNECT2                    = 7,
  929.     TE_ACCEPT1                    = 8,
  930.     TE_ACCEPT2                    = 9,
  931.     TE_ACCEPT3                    = 10,
  932.     TE_SND                        = 11,
  933.     TE_SNDDIS1                    = 12,
  934.     TE_SNDDIS2                    = 13,
  935.     TE_SNDREL                    = 14,
  936.     TE_SNDUDATA                    = 15,
  937.     TE_LISTEN                    = 16,
  938.     TE_RCVCONNECT                = 17,
  939.     TE_RCV                        = 18,
  940.     TE_RCVDIS1                    = 19,
  941.     TE_RCVDIS2                    = 20,
  942.     TE_RCVDIS3                    = 21,
  943.     TE_RCVREL                    = 22,
  944.     TE_RCVUDATA                    = 23,
  945.     TE_RCVUDERR                    = 24,
  946.     TE_PASS_CONN                = 25,
  947.     TE_BAD_EVENT                = 26
  948. };
  949.  
  950.  
  951. struct T_addr_ack {
  952.     long                             PRIM_type;                    /* Always T_ADDR_ACK */
  953.     long                             LOCADDR_length;
  954.     long                             LOCADDR_offset;
  955.     long                             REMADDR_length;
  956.     long                             REMADDR_offset;
  957. };
  958. typedef struct T_addr_ack                T_addr_ack;
  959.  
  960. struct T_addr_req {
  961.     long                             PRIM_type;                    /* Always T_ADDR_REQ */
  962. };
  963. typedef struct T_addr_req                T_addr_req;
  964.  
  965. struct T_bind_ack {
  966.     long                             PRIM_type;                    /* always T_BIND_ACK */
  967.     long                             ADDR_length;
  968.     long                             ADDR_offset;
  969.     unsigned long                     CONIND_number;
  970. };
  971. typedef struct T_bind_ack                T_bind_ack;
  972.  
  973. struct T_bind_req {
  974.     long                             PRIM_type;                    /* always T_BIND_REQ */
  975.     long                             ADDR_length;
  976.     long                             ADDR_offset;
  977.     unsigned long                     CONIND_number;
  978. };
  979. typedef struct T_bind_req                T_bind_req;
  980.  
  981. struct T_conn_con {
  982.     long                             PRIM_type;                    /* always T_CONN_CON */
  983.     long                             RES_length;                    /* responding address length */
  984.     long                             RES_offset;
  985.     long                             OPT_length;
  986.     long                             OPT_offset;
  987. };
  988. typedef struct T_conn_con                T_conn_con;
  989.  
  990. struct T_conn_ind {
  991.     long                             PRIM_type;                    /* always T_CONN_IND */
  992.     long                             SRC_length;
  993.     long                             SRC_offset;
  994.     long                             OPT_length;
  995.     long                             OPT_offset;
  996.     long                             SEQ_number;
  997. };
  998. typedef struct T_conn_ind                T_conn_ind;
  999.  
  1000. struct T_conn_req {
  1001.     long                             PRIM_type;                    /* always T_CONN_REQ */
  1002.     long                             DEST_length;
  1003.     long                             DEST_offset;
  1004.     long                             OPT_length;
  1005.     long                             OPT_offset;
  1006. };
  1007. typedef struct T_conn_req                T_conn_req;
  1008.  
  1009. struct T_conn_res {
  1010.     long                             PRIM_type;                    /* always T_CONN_RES */
  1011.     queue *                            QUEUE_ptr;
  1012.     long                             OPT_length;
  1013.     long                             OPT_offset;
  1014.     long                             SEQ_number;
  1015. };
  1016. typedef struct T_conn_res                T_conn_res;
  1017.  
  1018. struct T_data_ind {
  1019.     long                             PRIM_type;                    /* always T_DATA_IND */
  1020.     long                             MORE_flag;
  1021. };
  1022. typedef struct T_data_ind                T_data_ind;
  1023.  
  1024. struct T_data_req {
  1025.     long                             PRIM_type;                    /* always T_DATA_REQ */
  1026.     long                             MORE_flag;
  1027. };
  1028. typedef struct T_data_req                T_data_req;
  1029.  
  1030. struct T_discon_ind {
  1031.     long                             PRIM_type;                    /* always T_DISCON_IND */
  1032.     long                             DISCON_reason;
  1033.     long                             SEQ_number;
  1034. };
  1035. typedef struct T_discon_ind                T_discon_ind;
  1036.  
  1037. struct T_discon_req {
  1038.     long                             PRIM_type;                    /* always T_DISCON_REQ */
  1039.     long                             SEQ_number;
  1040. };
  1041. typedef struct T_discon_req                T_discon_req;
  1042.  
  1043. struct T_exdata_ind {
  1044.     long                             PRIM_type;                    /* always T_EXDATA_IND */
  1045.     long                             MORE_flag;
  1046. };
  1047. typedef struct T_exdata_ind                T_exdata_ind;
  1048.  
  1049. struct T_exdata_req {
  1050.     long                             PRIM_type;                    /* always T_EXDATA_REQ */
  1051.     long                             MORE_flag;
  1052. };
  1053. typedef struct T_exdata_req                T_exdata_req;
  1054.  
  1055. struct T_error_ack {
  1056.     long                             PRIM_type;                    /* always T_ERROR_ACK */
  1057.     long                             ERROR_prim;                    /* primitive in error */
  1058.     long                             TLI_error;
  1059.     long                             UNIX_error;
  1060. };
  1061. typedef struct T_error_ack                T_error_ack;
  1062.  
  1063. struct T_info_ack {
  1064.     long                             PRIM_type;                    /* always T_INFO_ACK */
  1065.     long                             TSDU_size;                    /* max TSDU size */
  1066.     long                             ETSDU_size;                    /* max ETSDU size */
  1067.     long                             CDATA_size;                    /* connect data size */
  1068.     long                             DDATA_size;                    /* disconnect data size */
  1069.     long                             ADDR_size;                    /* TSAP size */
  1070.     long                             OPT_size;                    /* options size */
  1071.     long                             TIDU_size;                    /* TIDU size */
  1072.     long                             SERV_type;                    /* service type */
  1073.     long                             CURRENT_state;                /* current state */
  1074.     long                             PROVIDER_flag;                /* provider flags (see xti.h for defines) */
  1075. };
  1076. typedef struct T_info_ack                T_info_ack;
  1077. /* Provider flags */
  1078. enum {
  1079.     SENDZERO                    = 0x0001,                        /* supports 0-length TSDU's */
  1080.     XPG4_1                        = 0x0002                        /* provider supports recent stuff */
  1081. };
  1082.  
  1083.  
  1084. struct T_info_req {
  1085.     long                             PRIM_type;                    /* always T_INFO_REQ */
  1086. };
  1087. typedef struct T_info_req                T_info_req;
  1088.  
  1089. struct T_ok_ack {
  1090.     long                             PRIM_type;                    /* always T_OK_ACK */
  1091.     long                             CORRECT_prim;
  1092. };
  1093. typedef struct T_ok_ack                    T_ok_ack;
  1094.  
  1095. struct T_optmgmt_ack {
  1096.     long                             PRIM_type;                    /* always T_OPTMGMT_ACK */
  1097.     long                             OPT_length;
  1098.     long                             OPT_offset;
  1099.     long                             MGMT_flags;
  1100. };
  1101. typedef struct T_optmgmt_ack            T_optmgmt_ack;
  1102.  
  1103. struct T_optmgmt_req {
  1104.     long                             PRIM_type;                    /* always T_OPTMGMT_REQ */
  1105.     long                             OPT_length;
  1106.     long                             OPT_offset;
  1107.     long                             MGMT_flags;
  1108. };
  1109. typedef struct T_optmgmt_req            T_optmgmt_req;
  1110.  
  1111. struct T_ordrel_ind {
  1112.     long                             PRIM_type;                    /* always T_ORDREL_IND */
  1113. };
  1114. typedef struct T_ordrel_ind                T_ordrel_ind;
  1115.  
  1116. struct T_ordrel_req {
  1117.     long                             PRIM_type;                    /* always T_ORDREL_REQ */
  1118. };
  1119. typedef struct T_ordrel_req                T_ordrel_req;
  1120.  
  1121. struct T_unbind_req {
  1122.     long                             PRIM_type;                    /* always T_UNBIND_REQ */
  1123. };
  1124. typedef struct T_unbind_req                T_unbind_req;
  1125.  
  1126. struct T_uderror_ind {
  1127.     long                             PRIM_type;                    /* always T_UDERROR_IND */
  1128.     long                             DEST_length;
  1129.     long                             DEST_offset;
  1130.     long                             OPT_length;
  1131.     long                             OPT_offset;
  1132.     long                             ERROR_type;
  1133. };
  1134. typedef struct T_uderror_ind            T_uderror_ind;
  1135.  
  1136. struct T_unitdata_ind {
  1137.     long                             PRIM_type;                    /* always T_UNITDATA_IND */
  1138.     long                             SRC_length;
  1139.     long                             SRC_offset;
  1140.     long                             OPT_length;
  1141.     long                             OPT_offset;
  1142. };
  1143. typedef struct T_unitdata_ind            T_unitdata_ind;
  1144.  
  1145. struct T_unitdata_req {
  1146.     long                             PRIM_type;                    /* always T_UNITDATA_REQ */
  1147.     long                             DEST_length;
  1148.     long                             DEST_offset;
  1149.     long                             OPT_length;
  1150.     long                             OPT_offset;
  1151. };
  1152. typedef struct T_unitdata_req            T_unitdata_req;
  1153.  
  1154. struct T_resolveaddr_ack {
  1155.     long                             PRIM_type;                    /* always T_RESOLVEADDR_ACK */
  1156.     long                             SEQ_number;
  1157.     long                             ADDR_length;
  1158.     long                             ADDR_offset;
  1159.     long                             ORIG_client;
  1160.     long                             ORIG_data;
  1161.     long                             TLI_error;
  1162.     long                             UNIX_error;
  1163. };
  1164. typedef struct T_resolveaddr_ack        T_resolveaddr_ack;
  1165.  
  1166. struct T_resolveaddr_req {
  1167.     long                             PRIM_type;                    /* always T_RESOLVEADDR_REQ */
  1168.     long                             SEQ_number;
  1169.     long                             ADDR_length;
  1170.     long                             ADDR_offset;
  1171.     long                             ORIG_client;
  1172.     long                             ORIG_data;
  1173.     long                             MAX_milliseconds;
  1174. };
  1175. typedef struct T_resolveaddr_req        T_resolveaddr_req;
  1176.  
  1177. struct T_unitreply_ind {
  1178.     long                             PRIM_type;                    /* Always T_UREPLY_IND */
  1179.     long                             SEQ_number;
  1180.     long                             OPT_length;
  1181.     long                             OPT_offset;
  1182.     long                             REP_flags;
  1183.     long                             TLI_error;
  1184.     long                             UNIX_error;
  1185. };
  1186. typedef struct T_unitreply_ind            T_unitreply_ind;
  1187.  
  1188. struct T_unitrequest_ind {
  1189.     long                             PRIM_type;                    /* Always T_UREQUEST_IND */
  1190.     long                             SEQ_number;
  1191.     long                             SRC_length;
  1192.     long                             SRC_offset;
  1193.     long                             OPT_length;
  1194.     long                             OPT_offset;
  1195.     long                             REQ_flags;
  1196. };
  1197. typedef struct T_unitrequest_ind        T_unitrequest_ind;
  1198.  
  1199. struct T_unitrequest_req {
  1200.     long                             PRIM_type;                    /* Always T_UREQUEST_REQ */
  1201.     long                             SEQ_number;
  1202.     long                             DEST_length;
  1203.     long                             DEST_offset;
  1204.     long                             OPT_length;
  1205.     long                             OPT_offset;
  1206.     long                             REQ_flags;
  1207. };
  1208. typedef struct T_unitrequest_req        T_unitrequest_req;
  1209.  
  1210. struct T_unitreply_req {
  1211.     long                             PRIM_type;                    /* Always T_UREPLY_REQ */
  1212.     long                             SEQ_number;
  1213.     long                             OPT_length;
  1214.     long                             OPT_offset;
  1215.     long                             REP_flags;
  1216. };
  1217. typedef struct T_unitreply_req            T_unitreply_req;
  1218.  
  1219. struct T_unitreply_ack {
  1220.     long                             PRIM_type;                    /* Always T_UREPLY_ACK */
  1221.     long                             SEQ_number;
  1222.     long                             TLI_error;
  1223.     long                             UNIX_error;
  1224. };
  1225. typedef struct T_unitreply_ack            T_unitreply_ack;
  1226.  
  1227. struct T_cancelrequest_req {
  1228.     long                             PRIM_type;                    /* Always T_CANCELREQUEST_REQ */
  1229.     long                             SEQ_number;
  1230. };
  1231. typedef struct T_cancelrequest_req        T_cancelrequest_req;
  1232.  
  1233. struct T_cancelreply_req {
  1234.     long                             PRIM_type;                    /* Always T_CANCELREPLY_REQ */
  1235.     long                             SEQ_number;
  1236. };
  1237. typedef struct T_cancelreply_req        T_cancelreply_req;
  1238.  
  1239. struct T_reply_ind {
  1240.     long                             PRIM_type;                    /* Always T_REPLY_IND */
  1241.     long                             SEQ_number;
  1242.     long                             OPT_length;
  1243.     long                             OPT_offset;
  1244.     long                             REP_flags;
  1245.     long                             TLI_error;
  1246.     long                             UNIX_error;
  1247. };
  1248. typedef struct T_reply_ind                T_reply_ind;
  1249.  
  1250. struct T_request_ind {
  1251.     long                             PRIM_type;                    /* Always T_REQUEST_IND */
  1252.     long                             SEQ_number;
  1253.     long                             OPT_length;
  1254.     long                             OPT_offset;
  1255.     long                             REQ_flags;
  1256. };
  1257. typedef struct T_request_ind            T_request_ind;
  1258.  
  1259. struct T_request_req {
  1260.     long                             PRIM_type;                    /* Always T_REQUEST_REQ */
  1261.     long                             SEQ_number;
  1262.     long                             OPT_length;
  1263.     long                             OPT_offset;
  1264.     long                             REQ_flags;
  1265. };
  1266. typedef struct T_request_req            T_request_req;
  1267.  
  1268. struct T_reply_req {
  1269.     long                             PRIM_type;                    /* Always T_REPLY_REQ */
  1270.     long                             SEQ_number;
  1271.     long                             OPT_length;
  1272.     long                             OPT_offset;
  1273.     long                             REP_flags;
  1274. };
  1275. typedef struct T_reply_req                T_reply_req;
  1276.  
  1277. struct T_reply_ack {
  1278.     long                             PRIM_type;                    /* Always T_REPLY_ACK */
  1279.     long                             SEQ_number;
  1280.     long                             TLI_error;
  1281.     long                             UNIX_error;
  1282. };
  1283. typedef struct T_reply_ack                T_reply_ack;
  1284.  
  1285. struct T_regname_req {
  1286.     long                             PRIM_type;                    /* Always T_REGNAME_REQ */
  1287.     long                             SEQ_number;                    /* Reply is sequence ack */
  1288.     long                             NAME_length;
  1289.     long                             NAME_offset;
  1290.     long                             ADDR_length;
  1291.     long                             ADDR_offset;
  1292.     long                             REQ_flags;
  1293. };
  1294. typedef struct T_regname_req            T_regname_req;
  1295.  
  1296. struct T_regname_ack {
  1297.     long                             PRIM_type;                    /* always T_REGNAME_ACK        */
  1298.     long                             SEQ_number;
  1299.     long                             REG_id;
  1300.     long                             ADDR_length;
  1301.     long                             ADDR_offset;
  1302. };
  1303. typedef struct T_regname_ack            T_regname_ack;
  1304.  
  1305. struct T_delname_req {
  1306.     long                             PRIM_type;                    /* Always T_DELNAME_REQ */
  1307.     long                             SEQ_number;                    /* Reply is sequence ack */
  1308.     long                             NAME_length;
  1309.     long                             NAME_offset;
  1310. };
  1311. typedef struct T_delname_req            T_delname_req;
  1312.  
  1313. struct T_lkupname_req {
  1314.     long                             PRIM_type;                    /* Always T_LKUPNAME_REQ */
  1315.     long                             SEQ_number;                    /* Reply is sequence ack */
  1316.     long                             NAME_length;                /* ... or T_LKUPNAME_CON */
  1317.     long                             NAME_offset;
  1318.     long                             ADDR_length;
  1319.     long                             ADDR_offset;
  1320.     long                             MAX_number;
  1321.     long                             MAX_milliseconds;
  1322.     long                             REQ_flags;
  1323. };
  1324. typedef struct T_lkupname_req            T_lkupname_req;
  1325.  
  1326. struct T_lkupname_con {
  1327.     long                             PRIM_type;                    /* Either T_LKUPNAME_CON */
  1328.     long                             SEQ_number;                    /* Or T_LKUPNAME_RES */
  1329.     long                             NAME_length;
  1330.     long                             NAME_offset;
  1331.     long                             RSP_count;
  1332.     long                             RSP_cumcount;
  1333. };
  1334. typedef struct T_lkupname_con            T_lkupname_con;
  1335.  
  1336. struct T_sequence_ack {
  1337.     long                             PRIM_type;                    /* always T_SEQUENCED_ACK        */
  1338.     long                             ORIG_prim;                    /* original primitive            */
  1339.     long                             SEQ_number;
  1340.     long                             TLI_error;
  1341.     long                             UNIX_error;
  1342. };
  1343. typedef struct T_sequence_ack            T_sequence_ack;
  1344.  
  1345. struct T_event_ind {
  1346.     long                             PRIM_type;                    /* always T_EVENT_IND            */
  1347.     long                             EVENT_code;
  1348.     long                             EVENT_cookie;
  1349. };
  1350. typedef struct T_event_ind                T_event_ind;
  1351.  
  1352. union T_primitives {
  1353.     long                        type;
  1354.  
  1355.     long                             primType;
  1356.     T_addr_ack                         taddrack;
  1357.     T_bind_ack                         tbindack;
  1358.     T_bind_req                         tbindreq;
  1359.     T_conn_con                         tconncon;
  1360.     T_conn_ind                         tconnind;
  1361.     T_conn_req                         tconnreq;
  1362.     T_conn_res                         tconnres;
  1363.     T_data_ind                         tdataind;
  1364.     T_data_req                         tdatareq;
  1365.     T_discon_ind                     tdisconind;
  1366.     T_discon_req                     tdisconreq;
  1367.     T_exdata_ind                     texdataind;
  1368.     T_exdata_req                     texdatareq;
  1369.     T_error_ack                     terrorack;
  1370.     T_info_ack                         tinfoack;
  1371.     T_info_req                         tinforeq;
  1372.     T_ok_ack                         tokack;
  1373.     T_optmgmt_ack                     toptmgmtack;
  1374.     T_optmgmt_req                     toptmgmtreq;
  1375.     T_ordrel_ind                     tordrelind;
  1376.     T_ordrel_req                     tordrelreq;
  1377.     T_unbind_req                     tunbindreq;
  1378.     T_uderror_ind                     tuderrorind;
  1379.     T_unitdata_ind                     tunitdataind;
  1380.     T_unitdata_req                     tunitdatareq;
  1381.     T_unitreply_ind                 tunitreplyind;
  1382.     T_unitrequest_ind                 tunitrequestind;
  1383.     T_unitrequest_req                 tunitrequestreq;
  1384.     T_unitreply_req                 tunitreplyreq;
  1385.     T_unitreply_ack                 tunitreplyack;
  1386.     T_reply_ind                     treplyind;
  1387.     T_request_ind                     trequestind;
  1388.     T_request_req                     trequestreq;
  1389.     T_reply_req                     treplyreq;
  1390.     T_reply_ack                     treplyack;
  1391.     T_cancelrequest_req             tcancelreqreq;
  1392.     T_resolveaddr_req                 tresolvereq;
  1393.     T_resolveaddr_ack                 tresolveack;
  1394.     T_regname_req                     tregnamereq;
  1395.     T_regname_ack                     tregnameack;
  1396.     T_delname_req                     tdelnamereq;
  1397.     T_lkupname_req                     tlkupnamereq;
  1398.     T_lkupname_con                     tlkupnamecon;
  1399.     T_sequence_ack                     tsequenceack;
  1400.     T_event_ind                     teventind;
  1401. };
  1402. typedef union T_primitives                T_primitives;
  1403. /* ***** From the Mentat "dlpi.h" ******/
  1404.  
  1405. /*
  1406.    This header file has encoded the values so an existing driver
  1407.    or user which was written with the Logical Link Interface(LLI)
  1408.    can migrate to the DLPI interface in a binary compatible manner.
  1409.    Any fields which require a specific format or value are flagged
  1410.    with a comment containing the message LLI compatibility.
  1411. */
  1412.  
  1413. /* DLPI revision definition history*/
  1414.  
  1415. enum {
  1416.     DL_CURRENT_VERSION            = 0x02,                            /* current version of dlpi */
  1417.     DL_VERSION_2                = 0x02                            /* version of dlpi March 12,1991 */
  1418. };
  1419.  
  1420.  
  1421. enum {
  1422.     DL_INFO_REQ                    = 0x00,                            /* Information Req, LLI compatibility */
  1423.     DL_INFO_ACK                    = 0x03,                            /* Information Ack, LLI compatibility */
  1424.     DL_ATTACH_REQ                = 0x0B,                            /* Attach a PPA */
  1425.     DL_DETACH_REQ                = 0x0C,                            /* Detach a PPA */
  1426.     DL_BIND_REQ                    = 0x01,                            /* Bind dlsap address, LLI compatibility */
  1427.     DL_BIND_ACK                    = 0x04,                            /* Dlsap address bound, LLI compatibility */
  1428.     DL_UNBIND_REQ                = 0x02,                            /* Unbind dlsap address, LLI compatibility */
  1429.     DL_OK_ACK                    = 0x06,                            /* Success acknowledgment, LLI compatibility */
  1430.     DL_ERROR_ACK                = 0x05,                            /* Error acknowledgment, LLI compatibility */
  1431.     DL_SUBS_BIND_REQ            = 0x1B,                            /* Bind Subsequent DLSAP address */
  1432.     DL_SUBS_BIND_ACK            = 0x1C,                            /* Subsequent DLSAP address bound */
  1433.     DL_SUBS_UNBIND_REQ            = 0x15,                            /* Subsequent unbind */
  1434.     DL_ENABMULTI_REQ            = 0x1D,                            /* Enable multicast addresses */
  1435.     DL_DISABMULTI_REQ            = 0x1E,                            /* Disable multicast addresses */
  1436.     DL_PROMISCON_REQ            = 0x1F,                            /* Turn on promiscuous mode */
  1437.     DL_PROMISCOFF_REQ            = 0x20,                            /* Turn off promiscuous mode */
  1438.     DL_UNITDATA_REQ                = 0x07,                            /* datagram send request, LLI compatibility */
  1439.     DL_UNITDATA_IND                = 0x08,                            /* datagram receive indication, LLI compatibility */
  1440.     DL_UDERROR_IND                = 0x09,                            /* datagram error indication, LLI compatibility */
  1441.     DL_UDQOS_REQ                = 0x0A,                            /* set QOS for subsequent datagram transmissions */
  1442.     DL_CONNECT_REQ                = 0x0D,                            /* Connect request */
  1443.     DL_CONNECT_IND                = 0x0E,                            /* Incoming connect indication */
  1444.     DL_CONNECT_RES                = 0x0F,                            /* Accept previous connect indication */
  1445.     DL_CONNECT_CON                = 0x10,                            /* Connection established */
  1446.     DL_TOKEN_REQ                = 0x11,                            /* Passoff token request */
  1447.     DL_TOKEN_ACK                = 0x12,                            /* Passoff token ack */
  1448.     DL_DISCONNECT_REQ            = 0x13,                            /* Disconnect request */
  1449.     DL_DISCONNECT_IND            = 0x14,                            /* Disconnect indication */
  1450.     DL_RESET_REQ                = 0x17,                            /* Reset service request */
  1451.     DL_RESET_IND                = 0x18,                            /* Incoming reset indication */
  1452.     DL_RESET_RES                = 0x19,                            /* Complete reset processing */
  1453.     DL_RESET_CON                = 0x1A,                            /* Reset processing complete */
  1454.     DL_DATA_ACK_REQ                = 0x21,                            /* data unit transmission request */
  1455.     DL_DATA_ACK_IND                = 0x22,                            /* Arrival of a command PDU */
  1456.     DL_DATA_ACK_STATUS_IND        = 0x23,                            /* Status indication of DATA_ACK_REQ*/
  1457.     DL_REPLY_REQ                = 0x24,                            /* Request a DLSDU from the remote */
  1458.     DL_REPLY_IND                = 0x25,                            /* Arrival of a command PDU */
  1459.     DL_REPLY_STATUS_IND            = 0x26,                            /* Status indication of REPLY_REQ */
  1460.     DL_REPLY_UPDATE_REQ            = 0x27,                            /* Hold a DLSDU for transmission */
  1461.     DL_REPLY_UPDATE_STATUS_IND    = 0x28,                            /* Status of REPLY_UPDATE req */
  1462.     DL_XID_REQ                    = 0x29,                            /* Request to send an XID PDU */
  1463.     DL_XID_IND                    = 0x2A,                            /* Arrival of an XID PDU */
  1464.     DL_XID_RES                    = 0x2B,                            /* request to send a response XID PDU*/
  1465.     DL_XID_CON                    = 0x2C,                            /* Arrival of a response XID PDU */
  1466.     DL_TEST_REQ                    = 0x2D,                            /* TEST command request */
  1467.     DL_TEST_IND                    = 0x2E,                            /* TEST response indication */
  1468.     DL_TEST_RES                    = 0x2F,                            /* TEST response */
  1469.     DL_TEST_CON                    = 0x30,                            /* TEST Confirmation */
  1470.     DL_PHYS_ADDR_REQ            = 0x31,                            /* Request to get physical addr */
  1471.     DL_PHYS_ADDR_ACK            = 0x32,                            /* Return physical addr */
  1472.     DL_SET_PHYS_ADDR_REQ        = 0x33,                            /* set physical addr */
  1473.     DL_GET_STATISTICS_REQ        = 0x34,                            /* Request to get statistics */
  1474.     DL_GET_STATISTICS_ACK        = 0x35                            /* Return statistics */
  1475. };
  1476.  
  1477. /* DLPI interface states*/
  1478. enum {
  1479.     DL_UNATTACHED                = 0x04,                            /* PPA not attached */
  1480.     DL_ATTACH_PENDING            = 0x05,                            /* Waiting ack of DL_ATTACH_REQ */
  1481.     DL_DETACH_PENDING            = 0x06,                            /* Waiting ack of DL_DETACH_REQ */
  1482.     DL_UNBOUND                    = 0x00,                            /* PPA attached, LLI compatibility */
  1483.     DL_BIND_PENDING                = 0x01,                            /* Waiting ack of DL_BIND_REQ, LLI compatibility */
  1484.     DL_UNBIND_PENDING            = 0x02,                            /* Waiting ack of DL_UNBIND_REQ, LLI compatibility */
  1485.     DL_IDLE                        = 0x03,                            /* dlsap bound, awaiting use, LLI compatibility */
  1486.     DL_UDQOS_PENDING            = 0x07,                            /* Waiting ack of DL_UDQOS_REQ */
  1487.     DL_OUTCON_PENDING            = 0x08,                            /* outgoing connection, awaiting DL_CONN_CON */
  1488.     DL_INCON_PENDING            = 0x09,                            /* incoming connection, awaiting DL_CONN_RES */
  1489.     DL_CONN_RES_PENDING            = 0x0A,                            /* Waiting ack of DL_CONNECT_RES */
  1490.     DL_DATAXFER                    = 0x0B,                            /* connection-oriented data transfer */
  1491.     DL_USER_RESET_PENDING        = 0x0C,                            /* user initiated reset, awaiting DL_RESET_CON */
  1492.     DL_PROV_RESET_PENDING        = 0x0D,                            /* provider initiated reset, awaiting DL_RESET_RES */
  1493.     DL_RESET_RES_PENDING        = 0x0E,                            /* Waiting ack of DL_RESET_RES */
  1494.     DL_DISCON8_PENDING            = 0x0F,                            /* Waiting ack of DL_DISC_REQ when in DL_OUTCON_PENDING */
  1495.     DL_DISCON9_PENDING            = 0x10,                            /* Waiting ack of DL_DISC_REQ when in DL_INCON_PENDING */
  1496.     DL_DISCON11_PENDING            = 0x11,                            /* Waiting ack of DL_DISC_REQ when in DL_DATAXFER */
  1497.     DL_DISCON12_PENDING            = 0x12,                            /* Waiting ack of DL_DISC_REQ when in DL_USER_RESET_PENDING */
  1498.     DL_DISCON13_PENDING            = 0x13,                            /* Waiting ack of DL_DISC_REQ when in DL_DL_PROV_RESET_PENDING */
  1499.     DL_SUBS_BIND_PND            = 0x14,                            /* Waiting ack of DL_SUBS_BIND_REQ */
  1500.     DL_SUBS_UNBIND_PND            = 0x15                            /* Waiting ack of DL_SUBS_UNBIND_REQ */
  1501. };
  1502.  
  1503. /* DL_ERROR_ACK error return values*/
  1504.  
  1505. enum {
  1506.     DL_ACCESS                    = 0x02,                            /* Improper permissions for request, LLI compatibility */
  1507.     DL_BADADDR                    = 0x01,                            /* DLSAP address in improper format or invalid */
  1508.     DL_BADCORR                    = 0x05,                            /* Sequence number not from outstanding DL_CONN_IND */
  1509.     DL_BADDATA                    = 0x06,                            /* User data exceeded provider limit */
  1510.     DL_BADPPA                    = 0x08,                            /* Specified PPA was invalid */
  1511.     DL_BADPRIM                    = 0x09,                            /* Primitive received is not known by DLS provider */
  1512.     DL_BADQOSPARAM                = 0x0A,                            /* QOS parameters contained invalid values */
  1513.     DL_BADQOSTYPE                = 0x0B,                            /* QOS structure type is unknown or unsupported */
  1514.     DL_BADSAP                    = 0x00,                            /* Bad LSAP selector, LLI compatibility */
  1515.     DL_BADTOKEN                    = 0x0C,                            /* Token used not associated with an active stream */
  1516.     DL_BOUND                    = 0x0D,                            /* Attempted second bind with dl_max_conind or    */
  1517.                                                                 /*    dl_conn_mgmt > 0 on same DLSAP or PPA */
  1518.     DL_INITFAILED                = 0x0E,                            /* Physical Link initialization failed */
  1519.     DL_NOADDR                    = 0x0F,                            /* Provider couldn't allocate alternate address */
  1520.     DL_NOTINIT                    = 0x10,                            /* Physical Link not initialized */
  1521.     DL_OUTSTATE                    = 0x03,                            /* Primitive issued in improper state, LLI compatibility */
  1522.     DL_SYSERR                    = 0x04,                            /* UNIX system error occurred, LLI compatibility */
  1523.     DL_UNSUPPORTED                = 0x07,                            /* Requested service not supplied by provider */
  1524.     DL_UNDELIVERABLE            = 0x11,                            /* Previous data unit could not be delivered */
  1525.     DL_NOTSUPPORTED                = 0x12,                            /* Primitive is known but not supported by DLS provider */
  1526.     DL_TOOMANY                    = 0x13,                            /* limit exceeded    */
  1527.     DL_NOTENAB                    = 0x14,                            /* Promiscuous mode not enabled */
  1528.     DL_BUSY                        = 0x15,                            /* Other streams for a particular PPA in the post-attached state */
  1529.     DL_NOAUTO                    = 0x16,                            /* Automatic handling of XID & TEST responses not supported */
  1530.     DL_NOXIDAUTO                = 0x17,                            /* Automatic handling of XID not supported */
  1531.     DL_NOTESTAUTO                = 0x18,                            /* Automatic handling of TEST not supported */
  1532.     DL_XIDAUTO                    = 0x19,                            /* Automatic handling of XID response */
  1533.     DL_TESTAUTO                    = 0x1A,                            /* AUtomatic handling of TEST response*/
  1534.     DL_PENDING                    = 0x1B                            /* pending outstanding connect indications */
  1535. };
  1536.  
  1537. /* DLPI media types supported*/
  1538.  
  1539. enum {
  1540.     DL_CSMACD                    = 0x00,                            /* IEEE 802.3 CSMA/CD network, LLI Compatibility */
  1541.     DL_TPB                        = 0x01,                            /* IEEE 802.4 Token Passing Bus, LLI Compatibility */
  1542.     DL_TPR                        = 0x02,                            /* IEEE 802.5 Token Passing Ring, LLI Compatibility */
  1543.     DL_METRO                    = 0x03,                            /* IEEE 802.6 Metro Net, LLI Compatibility */
  1544.     DL_ETHER                    = 0x04,                            /* Ethernet Bus, LLI Compatibility */
  1545.     DL_HDLC                        = 0x05,                            /* ISO HDLC protocol support, bit synchronous */
  1546.     DL_CHAR                        = 0x06,                            /* Character Synchronous protocol support, eg BISYNC */
  1547.     DL_CTCA                        = 0x07,                            /* IBM Channel-to-Channel Adapter */
  1548.     DL_FDDI                        = 0x08,                            /* Fiber Distributed data interface */
  1549.     DL_OTHER                    = 0x09                            /* Any other medium not listed above */
  1550. };
  1551.  
  1552. /*
  1553.    DLPI provider service supported.
  1554.    These must be allowed to be bitwise-OR for dl_service_mode in
  1555.    DL_INFO_ACK.
  1556. */
  1557. enum {
  1558.     DL_CODLS                    = 0x01,                            /* support connection-oriented service */
  1559.     DL_CLDLS                    = 0x02,                            /* support connectionless data link service */
  1560.     DL_ACLDLS                    = 0x04                            /* support acknowledged connectionless service*/
  1561. };
  1562.  
  1563. /*
  1564.    DLPI provider style.
  1565.    The DLPI provider style which determines whether a provider
  1566.    requires a DL_ATTACH_REQ to inform the provider which PPA
  1567.    user messages should be sent/received on.
  1568. */
  1569.  
  1570. enum {
  1571.     DL_STYLE1                    = 0x0500,                        /* PPA is implicitly bound by open(2) */
  1572.     DL_STYLE2                    = 0x0501                        /* PPA must be explicitly bound via DL_ATTACH_REQ */
  1573. };
  1574.  
  1575. /* DLPI Originator for Disconnect and Resets*/
  1576.  
  1577. enum {
  1578.     DL_PROVIDER                    = 0x0700,
  1579.     DL_USER                        = 0x0701
  1580. };
  1581.  
  1582. /* DLPI Disconnect Reasons*/
  1583.  
  1584. enum {
  1585.     DL_CONREJ_DEST_UNKNOWN        = 0x0800,
  1586.     DL_CONREJ_DEST_UNREACH_PERMANENT = 0x0801,
  1587.     DL_CONREJ_DEST_UNREACH_TRANSIENT = 0x0802,
  1588.     DL_CONREJ_QOS_UNAVAIL_PERMANENT = 0x0803,
  1589.     DL_CONREJ_QOS_UNAVAIL_TRANSIENT = 0x0804,
  1590.     DL_CONREJ_PERMANENT_COND    = 0x0805,
  1591.     DL_CONREJ_TRANSIENT_COND    = 0x0806,
  1592.     DL_DISC_ABNORMAL_CONDITION    = 0x0807,
  1593.     DL_DISC_NORMAL_CONDITION    = 0x0808,
  1594.     DL_DISC_PERMANENT_CONDITION    = 0x0809,
  1595.     DL_DISC_TRANSIENT_CONDITION    = 0x080A,
  1596.     DL_DISC_UNSPECIFIED            = 0x080B
  1597. };
  1598.  
  1599. /* DLPI Reset Reasons*/
  1600.  
  1601. enum {
  1602.     DL_RESET_FLOW_CONTROL        = 0x0900,
  1603.     DL_RESET_LINK_ERROR            = 0x0901,
  1604.     DL_RESET_RESYNCH            = 0x0902
  1605. };
  1606.  
  1607. /* DLPI status values for acknowledged connectionless data transfer*/
  1608.  
  1609. enum {
  1610.     DL_CMD_MASK                    = 0x0F,                            /* mask for command portion of status */
  1611.     DL_CMD_OK                    = 0x00,                            /* Command Accepted */
  1612.     DL_CMD_RS                    = 0x01,                            /* Unimplemented or inactivated service */
  1613.     DL_CMD_UE                    = 0x05,                            /* Data Link User interface error */
  1614.     DL_CMD_PE                    = 0x06,                            /* Protocol error */
  1615.     DL_CMD_IP                    = 0x07,                            /* Permanent implementation dependent error*/
  1616.     DL_CMD_UN                    = 0x09,                            /* Resources temporarily unavailable */
  1617.     DL_CMD_IT                    = 0x0F,                            /* Temporary implementation dependent error */
  1618.     DL_RSP_MASK                    = 0xF0,                            /* mask for response portion of status */
  1619.     DL_RSP_OK                    = 0x00,                            /* Response DLSDU present */
  1620.     DL_RSP_RS                    = 0x10,                            /* Unimplemented or inactivated service */
  1621.     DL_RSP_NE                    = 0x30,                            /* Response DLSDU never submitted */
  1622.     DL_RSP_NR                    = 0x40,                            /* Response DLSDU not requested */
  1623.     DL_RSP_UE                    = 0x50,                            /* Data Link User interface error */
  1624.     DL_RSP_IP                    = 0x70,                            /* Permanent implementation dependent error */
  1625.     DL_RSP_UN                    = 0x90,                            /* Resources temporarily unavailable */
  1626.     DL_RSP_IT                    = 0xF0                            /* Temporary implementation dependent error */
  1627. };
  1628.  
  1629. /* Service Class values for acknowledged connectionless data transfer*/
  1630.  
  1631. enum {
  1632.     DL_RQST_RSP                    = 0x01,                            /* Use acknowledge capability in MAC sublayer*/
  1633.     DL_RQST_NORSP                = 0x02                            /* No acknowledgement service requested */
  1634. };
  1635.  
  1636. /* DLPI address type definition*/
  1637.  
  1638. enum {
  1639.     DL_FACT_PHYS_ADDR            = 0x01,                            /* factory physical address */
  1640.     DL_CURR_PHYS_ADDR            = 0x02                            /* current physical address */
  1641. };
  1642.  
  1643. /* DLPI flag definitions*/
  1644.  
  1645. enum {
  1646.     DL_POLL_FINAL                = 0x01                            /* if set,indicates poll/final bit set*/
  1647. };
  1648.  
  1649. /* XID and TEST responses supported by the provider*/
  1650.  
  1651. enum {
  1652.     DL_AUTO_XID                    = 0x01,                            /* provider will respond to XID */
  1653.     DL_AUTO_TEST                = 0x02                            /* provider will respond to TEST */
  1654. };
  1655.  
  1656. /* Subsequent bind type*/
  1657.  
  1658. enum {
  1659.     DL_PEER_BIND                = 0x01,                            /* subsequent bind on a peer addr */
  1660.     DL_HIERARCHICAL_BIND        = 0x02                            /* subs_bind on a hierarchical addr*/
  1661. };
  1662.  
  1663. /* DLPI promiscuous mode definitions*/
  1664.  
  1665. enum {
  1666.     DL_PROMISC_PHYS                = 0x01,                            /* promiscuous mode at phys level */
  1667.     DL_PROMISC_SAP                = 0x02,                            /* promiscous mode at sap level */
  1668.     DL_PROMISC_MULTI            = 0x03                            /* promiscuous mode for multicast */
  1669. };
  1670.  
  1671. /*
  1672.    DLPI Quality Of Service definition for use in QOS structure definitions.
  1673.    The QOS structures are used in connection establishment, DL_INFO_ACK,
  1674.    and setting connectionless QOS values.
  1675. */
  1676.  
  1677. /*
  1678.    Throughput
  1679.    
  1680.    This parameter is specified for both directions.
  1681. */
  1682.  
  1683.  
  1684. struct dl_through_t {
  1685.     SInt32                             dl_target_value;            /* desired bits/second desired */
  1686.     SInt32                             dl_accept_value;            /* min. acceptable bits/second */
  1687. };
  1688. typedef struct dl_through_t                dl_through_t;
  1689. /*
  1690.    transit delay specification
  1691.    
  1692.    This parameter is specified for both directions.
  1693.    expressed in milliseconds assuming a DLSDU size of 128 octets.
  1694.    The scaling of the value to the current DLSDU size is provider dependent.
  1695. */
  1696.  
  1697. struct dl_transdelay_t {
  1698.     SInt32                             dl_target_value;            /* desired value of service */
  1699.     SInt32                             dl_accept_value;            /* min. acceptable value of service */
  1700. };
  1701. typedef struct dl_transdelay_t            dl_transdelay_t;
  1702. /*
  1703.    priority specification
  1704.    priority range is 0-100, with 0 being highest value.
  1705. */
  1706.  
  1707.  
  1708. struct dl_priority_t {
  1709.     SInt32                             dl_min;
  1710.     SInt32                             dl_max;
  1711. };
  1712. typedef struct dl_priority_t            dl_priority_t;
  1713. /* protection specification*/
  1714. enum {
  1715.     DL_NONE                        = 0x0B01,                        /* no protection supplied */
  1716.     DL_MONITOR                    = 0x0B02,                        /* protection against passive monitoring */
  1717.     DL_MAXIMUM                    = 0x0B03                        /* protection against modification, replay, addition, or deletion */
  1718. };
  1719.  
  1720.  
  1721. struct dl_protect_t {
  1722.     SInt32                             dl_min;
  1723.     SInt32                             dl_max;
  1724. };
  1725. typedef struct dl_protect_t                dl_protect_t;
  1726. /*
  1727.    Resilience specification
  1728.    probabilities are scaled by a factor of 10,000 with a time interval
  1729.    of 10,000 seconds.
  1730. */
  1731.  
  1732. struct dl_resilience_t {
  1733.     SInt32                             dl_disc_prob;                /* probability of provider init DISC */
  1734.     SInt32                             dl_reset_prob;                /* probability of provider init RESET */
  1735. };
  1736. typedef struct dl_resilience_t            dl_resilience_t;
  1737. /*
  1738.     QOS type definition to be used for negotiation with the
  1739.     remote end of a connection, or a connectionless unitdata request.
  1740.     There are two type definitions to handle the negotiation 
  1741.     process at connection establishment. The typedef dl_qos_range_t
  1742.     is used to present a range for parameters. This is used
  1743.     in the DL_CONNECT_REQ and DL_CONNECT_IND messages. The typedef
  1744.     dl_qos_sel_t is used to select a specific value for the QOS
  1745.     parameters. This is used in the DL_CONNECT_RES, DL_CONNECT_CON,
  1746.     and DL_INFO_ACK messages to define the selected QOS parameters
  1747.     for a connection.
  1748.  
  1749.     NOTE
  1750.     A DataLink provider which has unknown values for any of the fields
  1751.     will use a value of DL_UNKNOWN for all values in the fields.
  1752.  
  1753.     NOTE
  1754.     A QOS parameter value of DL_QOS_DONT_CARE informs the DLS
  1755.     provider the user requesting this value doesn't care 
  1756.     what the QOS parameter is set to. This value becomes the
  1757.     least possible value in the range of QOS parameters.
  1758.     The order of the QOS parameter range is then:
  1759.  
  1760.         DL_QOS_DONT_CARE < 0 < MAXIMUM QOS VALUE
  1761. */
  1762. enum {
  1763.     DL_UNKNOWN                    = -1,
  1764.     DL_QOS_DONT_CARE            = -2
  1765. };
  1766.  
  1767. /*
  1768.     Every QOS structure has the first 4 bytes containing a type
  1769.     field, denoting the definition of the rest of the structure.
  1770.     This is used in the same manner has the dl_primitive variable
  1771.     is in messages.
  1772.  
  1773.     The following list is the defined QOS structure type values and structures.
  1774. */
  1775. enum {
  1776.     DL_QOS_CO_RANGE1            = 0x0101,                        /* QOS range struct. for Connection modeservice */
  1777.     DL_QOS_CO_SEL1                = 0x0102,                        /* QOS selection structure */
  1778.     DL_QOS_CL_RANGE1            = 0x0103,                        /* QOS range struct. for connectionless*/
  1779.     DL_QOS_CL_SEL1                = 0x0104                        /* QOS selection for connectionless mode*/
  1780. };
  1781.  
  1782.  
  1783. struct dl_qos_co_range1_t {
  1784.     UInt32                             dl_qos_type;
  1785.     dl_through_t                     dl_rcv_throughput;            /* desired and acceptable*/
  1786.     dl_transdelay_t                 dl_rcv_trans_delay;            /* desired and acceptable*/
  1787.     dl_through_t                     dl_xmt_throughput;
  1788.     dl_transdelay_t                 dl_xmt_trans_delay;
  1789.     dl_priority_t                     dl_priority;                /* min and max values */
  1790.     dl_protect_t                     dl_protection;                /* min and max values */
  1791.     SInt32                             dl_residual_error;
  1792.     dl_resilience_t                 dl_resilience;
  1793. };
  1794. typedef struct dl_qos_co_range1_t        dl_qos_co_range1_t;
  1795.  
  1796. struct dl_qos_co_sel1_t {
  1797.     UInt32                             dl_qos_type;
  1798.     SInt32                             dl_rcv_throughput;
  1799.     SInt32                             dl_rcv_trans_delay;
  1800.     SInt32                             dl_xmt_throughput;
  1801.     SInt32                             dl_xmt_trans_delay;
  1802.     SInt32                             dl_priority;
  1803.     SInt32                             dl_protection;
  1804.     SInt32                             dl_residual_error;
  1805.     dl_resilience_t                 dl_resilience;
  1806. };
  1807. typedef struct dl_qos_co_sel1_t            dl_qos_co_sel1_t;
  1808.  
  1809. struct dl_qos_cl_range1_t {
  1810.     UInt32                             dl_qos_type;
  1811.     dl_transdelay_t                 dl_trans_delay;
  1812.     dl_priority_t                     dl_priority;
  1813.     dl_protect_t                     dl_protection;
  1814.     SInt32                             dl_residual_error;
  1815. };
  1816. typedef struct dl_qos_cl_range1_t        dl_qos_cl_range1_t;
  1817.  
  1818. struct dl_qos_cl_sel1_t {
  1819.     UInt32                             dl_qos_type;
  1820.     SInt32                             dl_trans_delay;
  1821.     SInt32                             dl_priority;
  1822.     SInt32                             dl_protection;
  1823.     SInt32                             dl_residual_error;
  1824. };
  1825. typedef struct dl_qos_cl_sel1_t            dl_qos_cl_sel1_t;
  1826. /*
  1827.     DLPI interface primitive definitions.
  1828.  
  1829.     Each primitive is sent as a stream message.    It is possible that
  1830.     the messages may be viewed as a sequence of bytes that have the
  1831.     following form without any padding. The structure definition
  1832.     of the following messages may have to change depending on the
  1833.     underlying hardware architecture and crossing of a hardware
  1834.     boundary with a different hardware architecture.
  1835.  
  1836.     Fields in the primitives having a name of the form
  1837.     dl_reserved cannot be used and have the value of
  1838.     binary zero, no bits turned on.
  1839.  
  1840.     Each message has the name defined followed by the
  1841.     stream message type (M_PROTO, M_PCPROTO, M_DATA)
  1842.  */
  1843. /* LOCAL MANAGEMENT SERVICE PRIMITIVES*/
  1844.  
  1845. /* DL_INFO_REQ, M_PCPROTO type*/
  1846.  
  1847.  
  1848. struct dl_info_req_t {
  1849.     UInt32                             dl_primitive;                /* set to DL_INFO_REQ */
  1850. };
  1851. typedef struct dl_info_req_t            dl_info_req_t;
  1852. /* DL_INFO_ACK, M_PCPROTO type*/
  1853.  
  1854. struct dl_info_ack_t {
  1855.     UInt32                             dl_primitive;                /* set to DL_INFO_ACK */
  1856.     UInt32                             dl_max_sdu;                    /* Max bytes in a DLSDU */
  1857.     UInt32                             dl_min_sdu;                    /* Min bytes in a DLSDU */
  1858.     UInt32                             dl_addr_length;                /* length of DLSAP address */
  1859.     UInt32                             dl_mac_type;                /* type of medium supported*/
  1860.     UInt32                             dl_reserved;                /* value set to zero */
  1861.     UInt32                             dl_current_state;            /* state of DLPI interface */
  1862.     SInt32                             dl_sap_length;                /* current length of SAP part of dlsap address */
  1863.     UInt32                             dl_service_mode;            /* CO, CL or ACL */
  1864.     UInt32                             dl_qos_length;                /* length of qos values */
  1865.     UInt32                             dl_qos_offset;                /* offset from beg. of block*/
  1866.     UInt32                             dl_qos_range_length;        /* available range of qos */
  1867.     UInt32                             dl_qos_range_offset;        /* offset from beg. of block*/
  1868.     UInt32                             dl_provider_style;            /* style1 or style2 */
  1869.     UInt32                             dl_addr_offset;                /* offset of the dlsap addr */
  1870.     UInt32                             dl_version;                    /* version number */
  1871.     UInt32                             dl_brdcst_addr_length;        /* length of broadcast addr */
  1872.     UInt32                             dl_brdcst_addr_offset;        /* offset from beg. of block*/
  1873.     UInt32                             dl_growth;                    /* set to zero */
  1874. };
  1875. typedef struct dl_info_ack_t            dl_info_ack_t;
  1876. /* DL_ATTACH_REQ, M_PROTO type*/
  1877.  
  1878. struct dl_attach_req_t {
  1879.     UInt32                             dl_primitive;                /* set to DL_ATTACH_REQ*/
  1880.     UInt32                             dl_ppa;                        /* id of the PPA */
  1881. };
  1882. typedef struct dl_attach_req_t            dl_attach_req_t;
  1883. /* DL_DETACH_REQ, M_PROTO type*/
  1884.  
  1885. struct dl_detach_req_t {
  1886.     UInt32                             dl_primitive;                /* set to DL_DETACH_REQ */
  1887. };
  1888. typedef struct dl_detach_req_t            dl_detach_req_t;
  1889. /* DL_BIND_REQ, M_PROTO type*/
  1890.  
  1891. struct dl_bind_req_t {
  1892.     UInt32                             dl_primitive;                /* set to DL_BIND_REQ */
  1893.     UInt32                             dl_sap;                        /* info to identify dlsap addr*/
  1894.     UInt32                             dl_max_conind;                /* max # of outstanding con_ind*/
  1895.     UInt16                             dl_service_mode;            /* CO, CL or ACL */
  1896.     UInt16                             dl_conn_mgmt;                /* if non-zero, is con-mgmt stream*/
  1897.     UInt32                             dl_xidtest_flg;                /* if set to 1 indicates automatic initiation of test and xid frames */
  1898. };
  1899. typedef struct dl_bind_req_t            dl_bind_req_t;
  1900. /* DL_BIND_ACK, M_PCPROTO type*/
  1901.  
  1902. struct dl_bind_ack_t {
  1903.     UInt32                             dl_primitive;                /* DL_BIND_ACK */
  1904.     UInt32                             dl_sap;                        /* DLSAP addr info */
  1905.     UInt32                             dl_addr_length;                /* length of complete DLSAP addr */
  1906.     UInt32                             dl_addr_offset;                /* offset from beginning of M_PCPROTO*/
  1907.     UInt32                             dl_max_conind;                /* allowed max. # of con-ind */
  1908.     UInt32                             dl_xidtest_flg;                /* responses supported by provider*/
  1909. };
  1910. typedef struct dl_bind_ack_t            dl_bind_ack_t;
  1911. /* DL_SUBS_BIND_REQ, M_PROTO type*/
  1912.  
  1913. struct dl_subs_bind_req_t {
  1914.     UInt32                             dl_primitive;                /* DL_SUBS_BIND_REQ */
  1915.     UInt32                             dl_subs_sap_offset;            /* offset of subs_sap */
  1916.     UInt32                             dl_subs_sap_length;            /* length of subs_sap */
  1917.     UInt32                             dl_subs_bind_class;            /* peer or hierarchical */
  1918. };
  1919. typedef struct dl_subs_bind_req_t        dl_subs_bind_req_t;
  1920. /* DL_SUBS_BIND_ACK, M_PCPROTO type*/
  1921.  
  1922. struct dl_subs_bind_ack_t {
  1923.     UInt32                             dl_primitive;                /* DL_SUBS_BIND_ACK */
  1924.     UInt32                             dl_subs_sap_offset;            /* offset of subs_sap */
  1925.     UInt32                             dl_subs_sap_length;            /* length of subs_sap */
  1926. };
  1927. typedef struct dl_subs_bind_ack_t        dl_subs_bind_ack_t;
  1928. /* DL_UNBIND_REQ, M_PROTO type*/
  1929.  
  1930. struct dl_unbind_req_t {
  1931.     UInt32                             dl_primitive;                /* DL_UNBIND_REQ */
  1932. };
  1933. typedef struct dl_unbind_req_t            dl_unbind_req_t;
  1934. /* DL_SUBS_UNBIND_REQ, M_PROTO type*/
  1935.  
  1936. struct dl_subs_unbind_req_t {
  1937.     UInt32                             dl_primitive;                /* DL_SUBS_UNBIND_REQ */
  1938.     UInt32                             dl_subs_sap_offset;            /* offset of subs_sap */
  1939.     UInt32                             dl_subs_sap_length;            /* length of subs_sap */
  1940. };
  1941. typedef struct dl_subs_unbind_req_t        dl_subs_unbind_req_t;
  1942. /* DL_OK_ACK, M_PCPROTO type*/
  1943.  
  1944. struct dl_ok_ack_t {
  1945.     UInt32                             dl_primitive;                /* DL_OK_ACK */
  1946.     UInt32                             dl_correct_primitive;        /* primitive being acknowledged */
  1947. };
  1948. typedef struct dl_ok_ack_t                dl_ok_ack_t;
  1949. /* DL_ERROR_ACK, M_PCPROTO type*/
  1950.  
  1951. struct dl_error_ack_t {
  1952.     UInt32                             dl_primitive;                /* DL_ERROR_ACK */
  1953.     UInt32                             dl_error_primitive;            /* primitive in error */
  1954.     UInt32                             dl_errno;                    /* DLPI error code */
  1955.     UInt32                             dl_unix_errno;                /* UNIX system error code */
  1956. };
  1957. typedef struct dl_error_ack_t            dl_error_ack_t;
  1958. /* DL_ENABMULTI_REQ, M_PROTO type*/
  1959.  
  1960. struct dl_enabmulti_req_t {
  1961.     UInt32                             dl_primitive;                /* DL_ENABMULTI_REQ */
  1962.     UInt32                             dl_addr_length;                /* length of multicast address */
  1963.     UInt32                             dl_addr_offset;                /* offset from beg. of M_PROTO block*/
  1964. };
  1965. typedef struct dl_enabmulti_req_t        dl_enabmulti_req_t;
  1966. /* DL_DISABMULTI_REQ, M_PROTO type*/
  1967.  
  1968. struct dl_disabmulti_req_t {
  1969.     UInt32                             dl_primitive;                /* DL_DISABMULTI_REQ */
  1970.     UInt32                             dl_addr_length;                /* length of multicast address */
  1971.     UInt32                             dl_addr_offset;                /* offset from beg. of M_PROTO block*/
  1972. };
  1973. typedef struct dl_disabmulti_req_t        dl_disabmulti_req_t;
  1974. /* DL_PROMISCON_REQ, M_PROTO type*/
  1975.  
  1976. struct dl_promiscon_req_t {
  1977.     UInt32                             dl_primitive;                /* DL_PROMISCON_REQ */
  1978.     UInt32                             dl_level;                    /* physical,SAP level or ALL multicast*/
  1979. };
  1980. typedef struct dl_promiscon_req_t        dl_promiscon_req_t;
  1981. /* DL_PROMISCOFF_REQ, M_PROTO type*/
  1982.  
  1983. struct dl_promiscoff_req_t {
  1984.     UInt32                             dl_primitive;                /* DL_PROMISCOFF_REQ */
  1985.     UInt32                             dl_level;                    /* Physical,SAP level or ALL multicast*/
  1986. };
  1987. typedef struct dl_promiscoff_req_t        dl_promiscoff_req_t;
  1988. /* Primitives to get and set the Physical address*/
  1989. /* DL_PHYS_ADDR_REQ, M_PROTO type*/
  1990.  
  1991.  
  1992. struct dl_phys_addr_req_t {
  1993.     UInt32                             dl_primitive;                /* DL_PHYS_ADDR_REQ */
  1994.     UInt32                             dl_addr_type;                /* factory or current physical addr */
  1995. };
  1996. typedef struct dl_phys_addr_req_t        dl_phys_addr_req_t;
  1997. /* DL_PHYS_ADDR_ACK, M_PCPROTO type*/
  1998.  
  1999. struct dl_phys_addr_ack_t {
  2000.     UInt32                             dl_primitive;                /* DL_PHYS_ADDR_ACK */
  2001.     UInt32                             dl_addr_length;                /* length of the physical addr */
  2002.     UInt32                             dl_addr_offset;                /* offset from beg. of block */
  2003. };
  2004. typedef struct dl_phys_addr_ack_t        dl_phys_addr_ack_t;
  2005. /* DL_SET_PHYS_ADDR_REQ, M_PROTO type*/
  2006.  
  2007. struct dl_set_phys_addr_req_t {
  2008.     UInt32                             dl_primitive;                /* DL_SET_PHYS_ADDR_REQ */
  2009.     UInt32                             dl_addr_length;                /* length of physical addr */
  2010.     UInt32                             dl_addr_offset;                /* offset from beg. of block */
  2011. };
  2012. typedef struct dl_set_phys_addr_req_t    dl_set_phys_addr_req_t;
  2013. /* Primitives to get statistics*/
  2014. /* DL_GET_STATISTICS_REQ, M_PROTO type*/
  2015.  
  2016.  
  2017. struct dl_get_statistics_req_t {
  2018.     UInt32                             dl_primitive;                /* DL_GET_STATISTICS_REQ */
  2019. };
  2020. typedef struct dl_get_statistics_req_t    dl_get_statistics_req_t;
  2021. /* DL_GET_STATISTICS_ACK, M_PCPROTO type*/
  2022.  
  2023. struct dl_get_statistics_ack_t {
  2024.     UInt32                             dl_primitive;                /* DL_GET_STATISTICS_ACK */
  2025.     UInt32                             dl_stat_length;                /* length of statistics structure*/
  2026.     UInt32                             dl_stat_offset;                /* offset from beg. of block */
  2027. };
  2028. typedef struct dl_get_statistics_ack_t    dl_get_statistics_ack_t;
  2029. /* CONNECTION-ORIENTED SERVICE PRIMITIVES*/
  2030.  
  2031. /* DL_CONNECT_REQ, M_PROTO type*/
  2032.  
  2033.  
  2034. struct dl_connect_req_t {
  2035.     UInt32                             dl_primitive;                /* DL_CONNECT_REQ */
  2036.     UInt32                             dl_dest_addr_length;        /* len. of dlsap addr*/
  2037.     UInt32                             dl_dest_addr_offset;        /* offset */
  2038.     UInt32                             dl_qos_length;                /* len. of QOS parm val*/
  2039.     UInt32                             dl_qos_offset;                /* offset */
  2040.     UInt32                             dl_growth;                    /* set to zero */
  2041. };
  2042. typedef struct dl_connect_req_t            dl_connect_req_t;
  2043. /* DL_CONNECT_IND, M_PROTO type*/
  2044.  
  2045. struct dl_connect_ind_t {
  2046.     UInt32                             dl_primitive;                /* DL_CONNECT_IND */
  2047.     UInt32                             dl_correlation;                /* provider's correlation token*/
  2048.     UInt32                             dl_called_addr_length;        /* length of called address */
  2049.     UInt32                             dl_called_addr_offset;        /* offset from beginning of block */
  2050.     UInt32                             dl_calling_addr_length;        /* length of calling address */
  2051.     UInt32                             dl_calling_addr_offset;        /* offset from beginning of block */
  2052.     UInt32                             dl_qos_length;                /* length of qos structure */
  2053.     UInt32                             dl_qos_offset;                /* offset from beginning of block */
  2054.     UInt32                             dl_growth;                    /* set to zero */
  2055. };
  2056. typedef struct dl_connect_ind_t            dl_connect_ind_t;
  2057. /* DL_CONNECT_RES, M_PROTO type*/
  2058.  
  2059. struct dl_connect_res_t {
  2060.     UInt32                             dl_primitive;                /* DL_CONNECT_RES */
  2061.     UInt32                             dl_correlation;                /* provider's correlation token */
  2062.     UInt32                             dl_resp_token;                /* token associated with responding stream */
  2063.     UInt32                             dl_qos_length;                /* length of qos structure */
  2064.     UInt32                             dl_qos_offset;                /* offset from beginning of block */
  2065.     UInt32                             dl_growth;                    /* set to zero */
  2066. };
  2067. typedef struct dl_connect_res_t            dl_connect_res_t;
  2068. /* DL_CONNECT_CON, M_PROTO type*/
  2069.  
  2070. struct dl_connect_con_t {
  2071.     UInt32                             dl_primitive;                /* DL_CONNECT_CON*/
  2072.     UInt32                             dl_resp_addr_length;        /* length of responder's address */
  2073.     UInt32                             dl_resp_addr_offset;        /* offset from beginning of block*/
  2074.     UInt32                             dl_qos_length;                /* length of qos structure */
  2075.     UInt32                             dl_qos_offset;                /* offset from beginning of block*/
  2076.     UInt32                             dl_growth;                    /* set to zero */
  2077. };
  2078. typedef struct dl_connect_con_t            dl_connect_con_t;
  2079. /* DL_TOKEN_REQ, M_PCPROTO type*/
  2080.  
  2081. struct dl_token_req_t {
  2082.     UInt32                             dl_primitive;                /* DL_TOKEN_REQ */
  2083. };
  2084. typedef struct dl_token_req_t            dl_token_req_t;
  2085. /* DL_TOKEN_ACK, M_PCPROTO type*/
  2086.  
  2087. struct dl_token_ack_t {
  2088.     UInt32                             dl_primitive;                /* DL_TOKEN_ACK */
  2089.     UInt32                             dl_token;                    /* Connection response token associated with the stream */
  2090. };
  2091. typedef struct dl_token_ack_t            dl_token_ack_t;
  2092. /* DL_DISCONNECT_REQ, M_PROTO type*/
  2093.  
  2094. struct dl_disconnect_req_t {
  2095.     UInt32                             dl_primitive;                /* DL_DISCONNECT_REQ */
  2096.     UInt32                             dl_reason;                    /*normal, abnormal, perm. or transient*/
  2097.     UInt32                             dl_correlation;                /* association with connect_ind */
  2098. };
  2099. typedef struct dl_disconnect_req_t        dl_disconnect_req_t;
  2100. /* DL_DISCONNECT_IND, M_PROTO type*/
  2101.  
  2102. struct dl_disconnect_ind_t {
  2103.     UInt32                             dl_primitive;                /* DL_DISCONNECT_IND */
  2104.     UInt32                             dl_originator;                /* USER or PROVIDER */
  2105.     UInt32                             dl_reason;                    /* permanent or transient */
  2106.     UInt32                             dl_correlation;                /* association with connect_ind */
  2107. };
  2108. typedef struct dl_disconnect_ind_t        dl_disconnect_ind_t;
  2109. /* DL_RESET_REQ, M_PROTO type*/
  2110.  
  2111. struct dl_reset_req_t {
  2112.     UInt32                             dl_primitive;                /* DL_RESET_REQ */
  2113. };
  2114. typedef struct dl_reset_req_t            dl_reset_req_t;
  2115. /* DL_RESET_IND, M_PROTO type*/
  2116.  
  2117. struct dl_reset_ind_t {
  2118.     UInt32                             dl_primitive;                /* DL_RESET_IND */
  2119.     UInt32                             dl_originator;                /* Provider or User */
  2120.     UInt32                             dl_reason;                    /* flow control, link error or resynch*/
  2121. };
  2122. typedef struct dl_reset_ind_t            dl_reset_ind_t;
  2123. /* DL_RESET_RES, M_PROTO type*/
  2124.  
  2125. struct dl_reset_res_t {
  2126.     UInt32                             dl_primitive;                /* DL_RESET_RES */
  2127. };
  2128. typedef struct dl_reset_res_t            dl_reset_res_t;
  2129. /* DL_RESET_CON, M_PROTO type*/
  2130.  
  2131. struct dl_reset_con_t {
  2132.     UInt32                             dl_primitive;                /* DL_RESET_CON */
  2133. };
  2134. typedef struct dl_reset_con_t            dl_reset_con_t;
  2135. /* CONNECTIONLESS SERVICE PRIMITIVES*/
  2136. /* DL_UNITDATA_REQ, M_PROTO type, with M_DATA block(s)*/
  2137.  
  2138.  
  2139. struct dl_unitdata_req_t {
  2140.     UInt32                             dl_primitive;                /* DL_UNITDATA_REQ */
  2141.     UInt32                             dl_dest_addr_length;        /* DLSAP length of dest. user */
  2142.     UInt32                             dl_dest_addr_offset;        /* offset from beg. of block */
  2143.     dl_priority_t                     dl_priority;                /* priority value */
  2144. };
  2145. typedef struct dl_unitdata_req_t        dl_unitdata_req_t;
  2146. /* DL_UNITDATA_IND, M_PROTO type, with M_DATA block(s)*/
  2147.  
  2148. struct dl_unitdata_ind_t {
  2149.     UInt32                             dl_primitive;                /* DL_UNITDATA_IND */
  2150.     UInt32                             dl_dest_addr_length;        /* DLSAP length of dest. user */
  2151.     UInt32                             dl_dest_addr_offset;        /* offset from beg. of block */
  2152.     UInt32                             dl_src_addr_length;            /* DLSAP addr length of sending user*/
  2153.     UInt32                             dl_src_addr_offset;            /* offset from beg. of block */
  2154.     UInt32                             dl_group_address;            /* set to one if multicast/broadcast*/
  2155. };
  2156. typedef struct dl_unitdata_ind_t        dl_unitdata_ind_t;
  2157. /*
  2158.    DL_UDERROR_IND, M_PROTO type
  2159.    (or M_PCPROTO type if LLI-based provider)
  2160. */
  2161.  
  2162. struct dl_uderror_ind_t {
  2163.     UInt32                             dl_primitive;                /* DL_UDERROR_IND */
  2164.     UInt32                             dl_dest_addr_length;        /* Destination DLSAP */
  2165.     UInt32                             dl_dest_addr_offset;        /* Offset from beg. of block */
  2166.     UInt32                             dl_unix_errno;                /* unix system error code*/
  2167.     UInt32                             dl_errno;                    /* DLPI error code */
  2168. };
  2169. typedef struct dl_uderror_ind_t            dl_uderror_ind_t;
  2170. /* DL_UDQOS_REQ, M_PROTO type*/
  2171.  
  2172. struct dl_udqos_req_t {
  2173.     UInt32                             dl_primitive;                /* DL_UDQOS_REQ */
  2174.     UInt32                             dl_qos_length;                /* length in bytes of requested qos*/
  2175.     UInt32                             dl_qos_offset;                /* offset from beg. of block */
  2176. };
  2177. typedef struct dl_udqos_req_t            dl_udqos_req_t;
  2178. /* Primitives to handle XID and TEST operations*/
  2179. /* DL_TEST_REQ, M_PROTO type*/
  2180.  
  2181.  
  2182. struct dl_test_req_t {
  2183.     UInt32                             dl_primitive;                /* DL_TEST_REQ */
  2184.     UInt32                             dl_flag;                    /* poll/final */
  2185.     UInt32                             dl_dest_addr_length;        /* DLSAP length of dest. user */
  2186.     UInt32                             dl_dest_addr_offset;        /* offset from beg. of block */
  2187. };
  2188. typedef struct dl_test_req_t            dl_test_req_t;
  2189. /* DL_TEST_IND, M_PROTO type*/
  2190.  
  2191. struct dl_test_ind_t {
  2192.     UInt32                             dl_primitive;                /* DL_TEST_IND */
  2193.     UInt32                             dl_flag;                    /* poll/final */
  2194.     UInt32                             dl_dest_addr_length;        /* dlsap length of dest. user */
  2195.     UInt32                             dl_dest_addr_offset;        /* offset from beg. of block */
  2196.     UInt32                             dl_src_addr_length;            /* dlsap length of source user */
  2197.     UInt32                             dl_src_addr_offset;            /* offset from beg. of block */
  2198. };
  2199. typedef struct dl_test_ind_t            dl_test_ind_t;
  2200. /* DL_TEST_RES, M_PROTO type*/
  2201.  
  2202. struct dl_test_res_t {
  2203.     UInt32                             dl_primitive;                /* DL_TEST_RES */
  2204.     UInt32                             dl_flag;                    /* poll/final */
  2205.     UInt32                             dl_dest_addr_length;        /* DLSAP length of dest. user */
  2206.     UInt32                             dl_dest_addr_offset;        /* offset from beg. of block */
  2207. };
  2208. typedef struct dl_test_res_t            dl_test_res_t;
  2209. /* DL_TEST_CON, M_PROTO type*/
  2210.  
  2211. struct dl_test_con_t {
  2212.     UInt32                             dl_primitive;                /* DL_TEST_CON */
  2213.     UInt32                             dl_flag;                    /* poll/final */
  2214.     UInt32                             dl_dest_addr_length;        /* dlsap length of dest. user */
  2215.     UInt32                             dl_dest_addr_offset;        /* offset from beg. of block */
  2216.     UInt32                             dl_src_addr_length;            /* dlsap length of source user */
  2217.     UInt32                             dl_src_addr_offset;            /* offset from beg. of block */
  2218. };
  2219. typedef struct dl_test_con_t            dl_test_con_t;
  2220. /* DL_XID_REQ, M_PROTO type*/
  2221.  
  2222. struct dl_xid_req_t {
  2223.     UInt32                             dl_primitive;                /* DL_XID_REQ */
  2224.     UInt32                             dl_flag;                    /* poll/final */
  2225.     UInt32                             dl_dest_addr_length;        /* dlsap length of dest. user */
  2226.     UInt32                             dl_dest_addr_offset;        /* offset from beg. of block */
  2227. };
  2228. typedef struct dl_xid_req_t                dl_xid_req_t;
  2229. /* DL_XID_IND, M_PROTO type*/
  2230.  
  2231. struct dl_xid_ind_t {
  2232.     UInt32                             dl_primitive;                /* DL_XID_IND */
  2233.     UInt32                             dl_flag;                    /* poll/final */
  2234.     UInt32                             dl_dest_addr_length;        /* dlsap length of dest. user */
  2235.     UInt32                             dl_dest_addr_offset;        /* offset from beg. of block */
  2236.     UInt32                             dl_src_addr_length;            /* dlsap length of source user */
  2237.     UInt32                             dl_src_addr_offset;            /* offset from beg. of block */
  2238. };
  2239. typedef struct dl_xid_ind_t                dl_xid_ind_t;
  2240. /* DL_XID_RES, M_PROTO type*/
  2241.  
  2242. struct dl_xid_res_t {
  2243.     UInt32                             dl_primitive;                /* DL_XID_RES */
  2244.     UInt32                             dl_flag;                    /* poll/final */
  2245.     UInt32                             dl_dest_addr_length;        /* DLSAP length of dest. user */
  2246.     UInt32                             dl_dest_addr_offset;        /* offset from beg. of block */
  2247. };
  2248. typedef struct dl_xid_res_t                dl_xid_res_t;
  2249. /* DL_XID_CON, M_PROTO type*/
  2250.  
  2251. struct dl_xid_con_t {
  2252.     UInt32                             dl_primitive;                /* DL_XID_CON */
  2253.     UInt32                             dl_flag;                    /* poll/final */
  2254.     UInt32                             dl_dest_addr_length;        /* dlsap length of dest. user */
  2255.     UInt32                             dl_dest_addr_offset;        /* offset from beg. of block */
  2256.     UInt32                             dl_src_addr_length;            /* dlsap length of source user */
  2257.     UInt32                             dl_src_addr_offset;            /* offset from beg. of block */
  2258. };
  2259. typedef struct dl_xid_con_t                dl_xid_con_t;
  2260. /* ACKNOWLEDGED CONNECTIONLESS SERVICE PRIMITIVES*/
  2261.  
  2262. /* DL_DATA_ACK_REQ, M_PROTO type*/
  2263.  
  2264.  
  2265. struct dl_data_ack_req_t {
  2266.     UInt32                             dl_primitive;                /* DL_DATA_ACK_REQ */
  2267.     UInt32                             dl_correlation;                /* User's correlation token */
  2268.     UInt32                             dl_dest_addr_length;        /* length of destination addr */
  2269.     UInt32                             dl_dest_addr_offset;        /* offset from beginning of block */
  2270.     UInt32                             dl_src_addr_length;            /* length of source address */
  2271.     UInt32                             dl_src_addr_offset;            /* offset from beginning of block */
  2272.     UInt32                             dl_priority;                /* priority */
  2273.     UInt32                             dl_service_class;            /* DL_RQST_RSP or DL_RQST_NORSP */
  2274. };
  2275. typedef struct dl_data_ack_req_t        dl_data_ack_req_t;
  2276. /* DL_DATA_ACK_IND, M_PROTO type*/
  2277.  
  2278. struct dl_data_ack_ind_t {
  2279.     UInt32                             dl_primitive;                /* DL_DATA_ACK_IND */
  2280.     UInt32                             dl_dest_addr_length;        /* length of destination addr */
  2281.     UInt32                             dl_dest_addr_offset;        /* offset from beginning of block */
  2282.     UInt32                             dl_src_addr_length;            /* length of source address */
  2283.     UInt32                             dl_src_addr_offset;            /* offset from beginning of block */
  2284.     UInt32                             dl_priority;                /* priority for data unit transm. */
  2285.     UInt32                             dl_service_class;            /* DL_RQST_RSP or DL_RQST_NORSP */
  2286. };
  2287. typedef struct dl_data_ack_ind_t        dl_data_ack_ind_t;
  2288. /* DL_DATA_ACK_STATUS_IND, M_PROTO type*/
  2289.  
  2290. struct dl_data_ack_status_ind_t {
  2291.     UInt32                             dl_primitive;                /* DL_DATA_ACK_STATUS_IND */
  2292.     UInt32                             dl_correlation;                /* User's correlation token */
  2293.     UInt32                             dl_status;                    /* success or failure of previous req*/
  2294. };
  2295. typedef struct dl_data_ack_status_ind_t    dl_data_ack_status_ind_t;
  2296. /* DL_REPLY_REQ, M_PROTO type*/
  2297.  
  2298. struct dl_reply_req_t {
  2299.     UInt32                             dl_primitive;                /* DL_REPLY_REQ */
  2300.     UInt32                             dl_correlation;                /* User's correlation token */
  2301.     UInt32                             dl_dest_addr_length;        /* length of destination address */
  2302.     UInt32                             dl_dest_addr_offset;        /* offset from beginning of block */
  2303.     UInt32                             dl_src_addr_length;            /* source address length */
  2304.     UInt32                             dl_src_addr_offset;            /* offset from beginning of block */
  2305.     UInt32                             dl_priority;                /* priority for data unit transmission*/
  2306.     UInt32                             dl_service_class;
  2307. };
  2308. typedef struct dl_reply_req_t            dl_reply_req_t;
  2309. /* DL_REPLY_IND, M_PROTO type*/
  2310.  
  2311. struct dl_reply_ind_t {
  2312.     UInt32                             dl_primitive;                /* DL_REPLY_IND */
  2313.     UInt32                             dl_dest_addr_length;        /* length of destination address */
  2314.     UInt32                             dl_dest_addr_offset;        /* offset from beginning of block*/
  2315.     UInt32                             dl_src_addr_length;            /* length of source address */
  2316.     UInt32                             dl_src_addr_offset;            /* offset from beginning of block */
  2317.     UInt32                             dl_priority;                /* priority for data unit transmission*/
  2318.     UInt32                             dl_service_class;            /* DL_RQST_RSP or DL_RQST_NORSP */
  2319. };
  2320. typedef struct dl_reply_ind_t            dl_reply_ind_t;
  2321. /* DL_REPLY_STATUS_IND, M_PROTO type*/
  2322.  
  2323. struct dl_reply_status_ind_t {
  2324.     UInt32                             dl_primitive;                /* DL_REPLY_STATUS_IND */
  2325.     UInt32                             dl_correlation;                /* User's correlation token */
  2326.     UInt32                             dl_status;                    /* success or failure of previous req*/
  2327. };
  2328. typedef struct dl_reply_status_ind_t    dl_reply_status_ind_t;
  2329. /* DL_REPLY_UPDATE_REQ, M_PROTO type*/
  2330.  
  2331. struct dl_reply_update_req_t {
  2332.     UInt32                             dl_primitive;                /* DL_REPLY_UPDATE_REQ */
  2333.     UInt32                             dl_correlation;                /* user's correlation token */
  2334.     UInt32                             dl_src_addr_length;            /* length of source address */
  2335.     UInt32                             dl_src_addr_offset;            /* offset from beginning of block */
  2336. };
  2337. typedef struct dl_reply_update_req_t    dl_reply_update_req_t;
  2338. /* DL_REPLY_UPDATE_STATUS_IND, M_PROTO type*/
  2339.  
  2340. struct dl_reply_update_status_ind_t {
  2341.     UInt32                             dl_primitive;                /* DL_REPLY_UPDATE_STATUS_IND */
  2342.     UInt32                             dl_correlation;                /* User's correlation token */
  2343.     UInt32                             dl_status;                    /* success or failure of previous req*/
  2344. };
  2345. typedef struct dl_reply_update_status_ind_t dl_reply_update_status_ind_t;
  2346.  
  2347. union DL_primitives {
  2348.     UInt32                             dl_primitive;
  2349.     dl_info_req_t                     info_req;
  2350.     dl_info_ack_t                     info_ack;
  2351.     dl_attach_req_t                 attach_req;
  2352.     dl_detach_req_t                 detach_req;
  2353.     dl_bind_req_t                     bind_req;
  2354.     dl_bind_ack_t                     bind_ack;
  2355.     dl_unbind_req_t                 unbind_req;
  2356.     dl_subs_bind_req_t                 subs_bind_req;
  2357.     dl_subs_bind_ack_t                 subs_bind_ack;
  2358.     dl_subs_unbind_req_t             subs_unbind_req;
  2359.     dl_ok_ack_t                     ok_ack;
  2360.     dl_error_ack_t                     error_ack;
  2361.     dl_connect_req_t                 connect_req;
  2362.     dl_connect_ind_t                 connect_ind;
  2363.     dl_connect_res_t                 connect_res;
  2364.     dl_connect_con_t                 connect_con;
  2365.     dl_token_req_t                     token_req;
  2366.     dl_token_ack_t                     token_ack;
  2367.     dl_disconnect_req_t             disconnect_req;
  2368.     dl_disconnect_ind_t             disconnect_ind;
  2369.     dl_reset_req_t                     reset_req;
  2370.     dl_reset_ind_t                     reset_ind;
  2371.     dl_reset_res_t                     reset_res;
  2372.     dl_reset_con_t                     reset_con;
  2373.     dl_unitdata_req_t                 unitdata_req;
  2374.     dl_unitdata_ind_t                 unitdata_ind;
  2375.     dl_uderror_ind_t                 uderror_ind;
  2376.     dl_udqos_req_t                     udqos_req;
  2377.     dl_enabmulti_req_t                 enabmulti_req;
  2378.     dl_disabmulti_req_t             disabmulti_req;
  2379.     dl_promiscon_req_t                 promiscon_req;
  2380.     dl_promiscoff_req_t             promiscoff_req;
  2381.     dl_phys_addr_req_t                 physaddr_req;
  2382.     dl_phys_addr_ack_t                 physaddr_ack;
  2383.     dl_set_phys_addr_req_t             set_physaddr_req;
  2384.     dl_get_statistics_req_t         get_statistics_req;
  2385.     dl_get_statistics_ack_t         get_statistics_ack;
  2386.     dl_test_req_t                     test_req;
  2387.     dl_test_ind_t                     test_ind;
  2388.     dl_test_res_t                     test_res;
  2389.     dl_test_con_t                     test_con;
  2390.     dl_xid_req_t                     xid_req;
  2391.     dl_xid_ind_t                     xid_ind;
  2392.     dl_xid_res_t                     xid_res;
  2393.     dl_xid_con_t                     xid_con;
  2394.     dl_data_ack_req_t                 data_ack_req;
  2395.     dl_data_ack_ind_t                 data_ack_ind;
  2396.     dl_data_ack_status_ind_t         data_ack_status_ind;
  2397.     dl_reply_req_t                     reply_req;
  2398.     dl_reply_ind_t                     reply_ind;
  2399.     dl_reply_status_ind_t             reply_status_ind;
  2400.     dl_reply_update_req_t             reply_update_req;
  2401.     dl_reply_update_status_ind_t     reply_update_status_ind;
  2402. };
  2403. typedef union DL_primitives                DL_primitives;
  2404. enum {
  2405.     DL_INFO_REQ_SIZE            = sizeof(dl_info_req_t),
  2406.     DL_INFO_ACK_SIZE            = sizeof(dl_info_ack_t),
  2407.     DL_ATTACH_REQ_SIZE            = sizeof(dl_attach_req_t),
  2408.     DL_DETACH_REQ_SIZE            = sizeof(dl_detach_req_t),
  2409.     DL_BIND_REQ_SIZE            = sizeof(dl_bind_req_t),
  2410.     DL_BIND_ACK_SIZE            = sizeof(dl_bind_ack_t),
  2411.     DL_UNBIND_REQ_SIZE            = sizeof(dl_unbind_req_t),
  2412.     DL_SUBS_BIND_REQ_SIZE        = sizeof(dl_subs_bind_req_t),
  2413.     DL_SUBS_BIND_ACK_SIZE        = sizeof(dl_subs_bind_ack_t),
  2414.     DL_SUBS_UNBIND_REQ_SIZE        = sizeof(dl_subs_unbind_req_t),
  2415.     DL_OK_ACK_SIZE                = sizeof(dl_ok_ack_t),
  2416.     DL_ERROR_ACK_SIZE            = sizeof(dl_error_ack_t),
  2417.     DL_CONNECT_REQ_SIZE            = sizeof(dl_connect_req_t),
  2418.     DL_CONNECT_IND_SIZE            = sizeof(dl_connect_ind_t),
  2419.     DL_CONNECT_RES_SIZE            = sizeof(dl_connect_res_t),
  2420.     DL_CONNECT_CON_SIZE            = sizeof(dl_connect_con_t),
  2421.     DL_TOKEN_REQ_SIZE            = sizeof(dl_token_req_t),
  2422.     DL_TOKEN_ACK_SIZE            = sizeof(dl_token_ack_t),
  2423.     DL_DISCONNECT_REQ_SIZE        = sizeof(dl_disconnect_req_t),
  2424.     DL_DISCONNECT_IND_SIZE        = sizeof(dl_disconnect_ind_t),
  2425.     DL_RESET_REQ_SIZE            = sizeof(dl_reset_req_t),
  2426.     DL_RESET_IND_SIZE            = sizeof(dl_reset_ind_t),
  2427.     DL_RESET_RES_SIZE            = sizeof(dl_reset_res_t),
  2428.     DL_RESET_CON_SIZE            = sizeof(dl_reset_con_t),
  2429.     DL_UNITDATA_REQ_SIZE        = sizeof(dl_unitdata_req_t),
  2430.     DL_UNITDATA_IND_SIZE        = sizeof(dl_unitdata_ind_t),
  2431.     DL_UDERROR_IND_SIZE            = sizeof(dl_uderror_ind_t),
  2432.     DL_UDQOS_REQ_SIZE            = sizeof(dl_udqos_req_t),
  2433.     DL_ENABMULTI_REQ_SIZE        = sizeof(dl_enabmulti_req_t),
  2434.     DL_DISABMULTI_REQ_SIZE        = sizeof(dl_disabmulti_req_t),
  2435.     DL_PROMISCON_REQ_SIZE        = sizeof(dl_promiscon_req_t),
  2436.     DL_PROMISCOFF_REQ_SIZE        = sizeof(dl_promiscoff_req_t),
  2437.     DL_PHYS_ADDR_REQ_SIZE        = sizeof(dl_phys_addr_req_t),
  2438.     DL_PHYS_ADDR_ACK_SIZE        = sizeof(dl_phys_addr_ack_t),
  2439.     DL_SET_PHYS_ADDR_REQ_SIZE    = sizeof(dl_set_phys_addr_req_t),
  2440.     DL_GET_STATISTICS_REQ_SIZE    = sizeof(dl_get_statistics_req_t),
  2441.     DL_GET_STATISTICS_ACK_SIZE    = sizeof(dl_get_statistics_ack_t),
  2442.     DL_XID_REQ_SIZE                = sizeof(dl_xid_req_t),
  2443.     DL_XID_IND_SIZE                = sizeof(dl_xid_ind_t),
  2444.     DL_XID_RES_SIZE                = sizeof(dl_xid_res_t),
  2445.     DL_XID_CON_SIZE                = sizeof(dl_xid_con_t),
  2446.     DL_TEST_REQ_SIZE            = sizeof(dl_test_req_t),
  2447.     DL_TEST_IND_SIZE            = sizeof(dl_test_ind_t),
  2448.     DL_TEST_RES_SIZE            = sizeof(dl_test_res_t),
  2449.     DL_TEST_CON_SIZE            = sizeof(dl_test_con_t),
  2450.     DL_DATA_ACK_REQ_SIZE        = sizeof(dl_data_ack_req_t),
  2451.     DL_DATA_ACK_IND_SIZE        = sizeof(dl_data_ack_ind_t),
  2452.     DL_DATA_ACK_STATUS_IND_SIZE    = sizeof(dl_data_ack_status_ind_t),
  2453.     DL_REPLY_REQ_SIZE            = sizeof(dl_reply_req_t),
  2454.     DL_REPLY_IND_SIZE            = sizeof(dl_reply_ind_t),
  2455.     DL_REPLY_STATUS_IND_SIZE    = sizeof(dl_reply_status_ind_t),
  2456.     DL_REPLY_UPDATE_REQ_SIZE    = sizeof(dl_reply_update_req_t),
  2457.     DL_REPLY_UPDATE_STATUS_IND_SIZE = sizeof(dl_reply_update_status_ind_t)
  2458. };
  2459.  
  2460. enum {
  2461.     DL_IOC_HDR_INFO                = ((MIOC_DLPI << 8) | 10)        /* Fast path request */
  2462. };
  2463.  
  2464. /* ***** From the Mentat "modnames.h" ******/
  2465.  
  2466.  
  2467. #define    MI_AFU_NAME            "afu"
  2468. #define    MI_AHARP_NAME        "ahar"
  2469. #define    MI_AHENET_NAME        "ahen"
  2470. #define MI_ARP_NAME            "arp"
  2471. #define MI_ARPM_NAME        "arpm"
  2472. #define MI_COURMUX_NAME        "courmux"
  2473. #define    MI_CLONE_NAME        "clone"
  2474. #define    MI_DLB_NAME            "dlb"
  2475. #define    MI_DLM_NAME            "dlm"
  2476. #define    MI_DMODD_NAME        "disdlpi"
  2477. #define    MI_DMODT_NAME        "distpi"
  2478. #define    MI_DN_NAME            "dn"
  2479. #define    MI_DNF_NAME            "dnf"
  2480. #define    MI_DRVE_NAME        "drve"
  2481. #define MI_ECHO_NAME        "echo"
  2482. #define MI_ENXR_NAME        "enxr"
  2483. #define MI_RAWIP_NAME        "rawip"
  2484. #define MI_RAWIPM_NAME        "rawipm"
  2485. #define    MI_HAVOC_NAME        "havoc"
  2486. #define    MI_HAVOCM_NAME        "havocm"
  2487. #define MI_IP_NAME            "ip"
  2488. #define MI_IPM_NAME            "ipm"
  2489. #define MI_IPX_NAME            "ipx"
  2490. #define MI_LOG_NAME            "log"
  2491. #define    MI_MODE_NAME        "mode"
  2492. #define    MI_MUX_NAME            "mux"
  2493. #define MI_NECHO_NAME        "necho"
  2494. #define MI_NPEP_NAME        "npep"
  2495. #define MI_NULS_NAME        "nuls"
  2496. #define MI_NULZ_NAME        "nulz"
  2497. #define    MI_PASS_NAME        "pass"
  2498. #define    MI_PIPEMOD_NAME        "pipemod"
  2499. #define    MI_SAD_NAME            "sad"
  2500. #define    MI_SC_NAME            "sc"
  2501. #define    MI_SOCKMOD_NAME        "sockmod"
  2502. #define    MI_SPASS_NAME        "spass"
  2503. #define    MI_SPX_NAME            "spx"
  2504. #define MI_STH_NAME            "mi_sth"
  2505. #define MI_TCP_NAME            "tcp"
  2506. #define MI_TCPM_NAME        "tcpm"
  2507. #define MI_TIMOD_NAME        "timod"
  2508. #define MI_TIRDWR_NAME        "tirdwr"
  2509. #define    MI_TMOD_NAME        "tmod"
  2510. #define    MI_TMUX_NAME        "tmux"
  2511. #define    MI_TPIT_NAME        "tpit"
  2512. #define    MI_TRSR_NAME        "trsr"
  2513. #define    MI_TRXR_NAME        "trxr"
  2514. #define MI_UDP_NAME            "udp"
  2515. #define MI_UDPM_NAME        "udpm"
  2516. #define MI_WELD_NAME        "mi_weld"
  2517. #define    MI_XDG_NAME            "xdg"
  2518. #define    MI_XECHO_NAME        "xecho"
  2519. #define    MI_XF_NAME            "xf"
  2520. #define    MI_XFIPX_NAME        "xfipx"
  2521. #define    MI_XFXNS_NAME        "xfxns"
  2522. #define    MI_XPE_NAME            "xpe"
  2523. #define    MI_XS_NAME            "xs"
  2524. #define    MI_XTINDG_NAME        "xtindg"
  2525. #define    MI_XTINVC_NAME        "xtinvc"
  2526. #define    MI_XTM_NAME            "xtm"
  2527. #define    MI_XTMIP_NAME        "xtmip"
  2528.  
  2529. #define    MI_AFU_DEVICE        "/dev/afu"
  2530. #define MI_ARP_DEVICE        "/dev/arp"
  2531. #define MI_COURMUX_DEVICE    "/dev/courmux"
  2532. #define    MI_CLONE_DEVICE        "/dev/clone"
  2533. #define    MI_DLB_DEVICE        "/dev/dlb"
  2534. #define    MI_DN_DEVICE        "/dev/dn"
  2535. #define    MI_DNF_DEVICE        "/dev/dnf"
  2536. #define    MI_DRVE_DEVICE        "/dev/drve"
  2537. #define MI_ECHO_DEVICE        "/dev/echo"
  2538. #define MI_RAWIP_DEVICE        "/dev/rawip"
  2539. #define    MI_HAVOC_DEVICE        "/dev/havoc"
  2540. #define MI_IP_DEVICE        "/dev/ip"
  2541. #define MI_IPX_DEVICE        "/dev/ipx"
  2542. #define MI_LOG_DEVICE        "/dev/log"
  2543. #define    MI_MODE_DEVICE        "/dev/mode"
  2544. #define    MI_MUX_DEVICE        "/dev/mux"
  2545. #define MI_NECHO_DEVICE        "/dev/necho"
  2546. #define MI_NPEP_DEVICE        "/dev/npep"
  2547. #define MI_NULS_DEVICE        "/dev/nuls"
  2548. #define MI_NULZ_DEVICE        "/dev/nulz"
  2549. #define    MI_SAD_DEVICE        "/dev/sad"
  2550. #define    MI_SPX_DEVICE        "/dev/spx"
  2551. #define MI_TCP_DEVICE        "/dev/tcp"
  2552. #define    MI_TMUX_DEVICE        "/dev/tmux"
  2553. #define    MI_TMUX0_DEVICE        "/dev/tmux#0"
  2554. #define    MI_TMUX1_DEVICE        "/dev/tmux#1"
  2555. #define    MI_TPIT_DEVICE        "/dev/tpit"
  2556. #define MI_UDP_DEVICE        "/dev/udp"
  2557. #define    MI_XDG_DEVICE        "/dev/xdg"
  2558. #define    MI_XECHO_DEVICE        "/dev/xecho"
  2559. #define    MI_XF_DEVICE        "/dev/xf"
  2560. #define    MI_XPE_DEVICE        "/dev/xpe"
  2561. #define    MI_XS_DEVICE        "/dev/xs"
  2562. #define    MI_XTINDG_DEVICE    "/dev/xtindg"
  2563. #define    MI_XTINVC_DEVICE    "/dev/xtinvc"
  2564.  
  2565.  
  2566. /* Streamtab entries */
  2567. #define    MI_AFU_STREAMTAB    afuinfo
  2568. #define    MI_AHARP_STREAMTAB    aharinfo
  2569. #define    MI_AHENET_STREAMTAB    aheninfo
  2570. #define MI_ARP_STREAMTAB    arpinfo
  2571. #define MI_ARPM_STREAMTAB    arpminfo
  2572. #define MI_COURMUX_STREAMTAB    courmuxinfo
  2573. #define    MI_CLONE_STREAMTAB    cloneinfo
  2574. #define    MI_DLB_STREAMTAB    dlbinfo
  2575. #define    MI_DLM_STREAMTAB    dlminfo
  2576. #define    MI_DMODD_STREAMTAB    dmoddinfo
  2577. #define    MI_DMODT_STREAMTAB    dmodtinfo
  2578. #define    MI_DN_STREAMTAB        dninfo
  2579. #define    MI_DNF_STREAMTAB    dnfinfo
  2580. #define    MI_DRVE_STREAMTAB    drveinfo
  2581. #define MI_ECHO_STREAMTAB    echoinfo
  2582. #define MI_ENXR_STREAMTAB    enxrinfo
  2583. #define    MI_HAVOC_STREAMTAB    hvcinfo
  2584. #define    MI_HAVOCM_STREAMTAB    hvcminfo
  2585. #define MI_IP_STREAMTAB        ipinfo
  2586. #define MI_IPM_STREAMTAB    ipminfo
  2587. #define MI_IPX_STREAMTAB    ipxinfo
  2588. #define MI_LOG_STREAMTAB    loginfo
  2589. #define    MI_MODE_STREAMTAB    modeinfo
  2590. #define    MI_MUX_STREAMTAB    muxinfo
  2591. #define MI_NECHO_STREAMTAB    nechoinfo
  2592. #define MI_NPEP_STREAMTAB    npepinfo
  2593. #define MI_NULS_STREAMTAB    nulsinfo
  2594. #define MI_NULZ_STREAMTAB    nulzinfo
  2595. #define    MI_PASS_STREAMTAB    passinfo
  2596. #define    MI_PIPEMOD_STREAMTAB    pmodinfo
  2597. #define MI_RAWIP_STREAMTAB    rawipinfo
  2598. #define MI_RAWIPM_STREAMTAB    rawipminfo
  2599. #define    MI_SAD_STREAMTAB    sadinfo
  2600. #define    MI_SC_STREAMTAB        scinfo
  2601. #define    MI_SOCKMOD_STREAMTAB    sockmodinfo
  2602. #define    MI_SPASS_STREAMTAB    spassinfo
  2603. #define MI_SPX_STREAMTAB    spxinfo
  2604. #define MI_STH_STREAMTAB    mi_sthinfo
  2605. #define MI_TCP_STREAMTAB    tcpinfo
  2606. #define MI_TCPM_STREAMTAB    tcpminfo
  2607. #define MI_TIMOD_STREAMTAB    timodinfo
  2608. #define MI_TIRDWR_STREAMTAB    tirdwrinfo
  2609. #define    MI_TMOD_STREAMTAB    tmodinfo
  2610. #define    MI_TMUX_STREAMTAB    tmuxinfo
  2611. #define MI_TPIT_STREAMTAB    tpitinfo
  2612. #define MI_TRSR_STREAMTAB    trsrinfo
  2613. #define MI_TRXR_STREAMTAB    trxrinfo
  2614. #define MI_UDP_STREAMTAB    udpinfo
  2615. #define MI_UDPM_STREAMTAB    udpminfo
  2616. #define MI_WELD_STREAMTAB    mi_weldinfo
  2617. #define    MI_XDG_STREAMTAB    xdginfo
  2618. #define    MI_XECHO_STREAMTAB    xechoinfo
  2619. #define    MI_XF_STREAMTAB        xfinfo
  2620. #define    MI_XFIPX_STREAMTAB    xfipxinfo
  2621. #define    MI_XFXNS_STREAMTAB    xfxnsinfo
  2622. #define    MI_XPE_STREAMTAB    xpeinfo
  2623. #define    MI_XS_STREAMTAB        xsinfo
  2624. #define    MI_XTINDG_STREAMTAB    xtindginfo
  2625. #define    MI_XTINVC_STREAMTAB    xtinvcinfo
  2626. #define    MI_XTM_STREAMTAB    xtminfo
  2627. #define    MI_XTMIP_STREAMTAB    xtmipinfo
  2628.  
  2629.  
  2630. #define    MI_AFU_DEVFLAG        afudevflag
  2631. #define    MI_AHARP_DEVFLAG    ahardevflag
  2632. #define    MI_AHENET_DEVFLAG    ahendevflag
  2633. #define MI_ARP_DEVFLAG        arpdevflag
  2634. #define MI_ARPM_DEVFLAG        arpmdevflag
  2635. #define MI_COURMUX_DEVFLAG    courmuxdevflag
  2636. #define    MI_CLONE_DEVFLAG    clonedevflag
  2637. #define    MI_DLB_DEVFLAG        dlbdevflag
  2638. #define    MI_DLM_DEVFLAG        dlmdevflag
  2639. #define    MI_DMODD_DEVFLAG    dmodddevflag
  2640. #define    MI_DMODT_DEVFLAG    dmodtdevflag
  2641. #define    MI_DN_DEVFLAG        dndevflag
  2642. #define    MI_DNF_DEVFLAG        dnfdevflag
  2643. #define    MI_DRVE_DEVFLAG        drvedevflag
  2644. #define MI_ECHO_DEVFLAG        echodevflag
  2645. #define MI_ENXR_DEVFLAG        enxrdevflag
  2646. #define    MI_HAVOC_DEVFLAG    hvcdevflag
  2647. #define    MI_HAVOCM_DEVFLAG    hvcmdevflag
  2648. #define MI_IP_DEVFLAG        ipdevflag
  2649. #define MI_IPM_DEVFLAG        ipmdevflag
  2650. #define MI_IPX_DEVFLAG        ipxdevflag
  2651. #define MI_LOG_DEVFLAG        logdevflag
  2652. #define    MI_MODE_DEVFLAG        modedevflag
  2653. #define    MI_MUX_DEVFLAG        muxdevflag
  2654. #define MI_NECHO_DEVFLAG    nechodevflag
  2655. #define MI_NPEP_DEVFLAG        npepdevflag
  2656. #define MI_NULS_DEVFLAG        nulsdevflag
  2657. #define MI_NULZ_DEVFLAG        nulzdevflag
  2658. #define    MI_PASS_DEVFLAG        passdevflag
  2659. #define    MI_PIPEMOD_DEVFLAG    pipemoddevflag
  2660. #define MI_RAWIP_DEVFLAG    rawipdevflag
  2661. #define MI_RAWIPM_DEVFLAG    rawipmdevflag
  2662.  
  2663. #define    MI_SAD_DEVFLAG        saddevflag
  2664. #define    MI_SC_DEVFLAG        scdevflag
  2665. #define    MI_SOCKMOD_DEVFLAG    sockmoddevflag
  2666. #define    MI_SPASS_DEVFLAG    spassdevflag
  2667. #define MI_SPX_DEVFLAG        spxdevflag
  2668. #define MI_TCP_DEVFLAG        tcpdevflag
  2669. #define MI_TCPM_DEVFLAG        tcpmdevflag
  2670. #define MI_TIMOD_DEVFLAG    timoddevflag
  2671. #define MI_TIRDWR_DEVFLAG    tirdwrdevflag
  2672. #define    MI_TMOD_DEVFLAG        tmoddevflag
  2673. #define    MI_TMUX_DEVFLAG        tmuxdevflag
  2674. #define    MI_TPIT_DEVFLAG        tpitdevflag
  2675. #define    MI_TRSR_DEVFLAG        trsrdevflag
  2676. #define    MI_TRXR_DEVFLAG        trxrdevflag
  2677. #define MI_UDP_DEVFLAG        udpdevflag
  2678. #define MI_UDPM_DEVFLAG        udpmdevflag
  2679. #define    MI_XDG_DEVFLAG        xdgdevflag
  2680. #define    MI_XECHO_DEVFLAG    xechodevflag
  2681. #define    MI_XF_DEVFLAG        xfdevflag
  2682. #define    MI_XFIPX_DEVFLAG    xfipxdevflag
  2683. #define    MI_XFXNS_DEVFLAG    xfxnsdevflag
  2684. #define    MI_XPE_DEVFLAG        xpedevflag
  2685. #define    MI_XS_DEVFLAG        xsdevflag
  2686. #define    MI_XTINDG_DEVFLAG    xtindgdevflag
  2687. #define    MI_XTINVC_DEVFLAG    xtinvcdevflag
  2688. #define    MI_XTM_DEVFLAG        xtmdevflag
  2689. #define    MI_XTMIP_DEVFLAG    xtmipdevflag
  2690.  
  2691. #define    MI_AFU_SQLVL        SQLVL_QUEUEPAIR
  2692. #define    MI_AHARP_SQLVL        SQLVL_QUEUE
  2693. #define    MI_AHENET_SQLVL        SQLVL_QUEUE
  2694. #define MI_ARP_SQLVL        SQLVL_MODULE
  2695. #define MI_ARPM_SQLVL        SQLVL_MODULE
  2696. #define MI_COURMUX_SQLVL    SQLVL_MODULE
  2697. #define    MI_CLONE_SQLVL        SQLVL_MODULE
  2698. #define    MI_DLB_SQLVL        SQLVL_QUEUE
  2699. #define    MI_DLM_SQLVL        SQLVL_QUEUE
  2700. #define    MI_DMODD_SQLVL        SQLVL_QUEUE
  2701. #define    MI_DMODT_SQLVL        SQLVL_QUEUE
  2702. #define    MI_DN_SQLVL            SQLVL_QUEUE
  2703. #define    MI_DNF_SQLVL        SQLVL_QUEUE
  2704. #define    MI_DRVE_SQLVL        SQLVL_QUEUEPAIR
  2705. #define MI_ECHO_SQLVL        SQLVL_QUEUE
  2706. #define MI_ENXR_SQLVL        SQLVL_QUEUE
  2707. #define MI_RAWIP_SQLVL        SQLVL_QUEUE
  2708. #define MI_RAWIPM_SQLVL        SQLVL_QUEUE
  2709. #define    MI_HAVOC_SQLVL        SQLVL_QUEUE
  2710. #define    MI_HAVOCM_SQLVL        SQLVL_QUEUE
  2711. #define MI_IP_SQLVL            SQLVL_QUEUEPAIR
  2712. #define MI_IPM_SQLVL        SQLVL_QUEUEPAIR
  2713. #define MI_IPX_SQLVL        SQLVL_QUEUE
  2714. #define MI_LOG_SQLVL        SQLVL_MODULE
  2715. #define    MI_MODE_SQLVL        SQLVL_QUEUEPAIR
  2716. #define    MI_MUX_SQLVL        SQLVL_MODULE
  2717. #define MI_NECHO_SQLVL        SQLVL_QUEUE
  2718.  
  2719. #define MI_NPEP_SQLVL        SQLVL_QUEUE
  2720. #define MI_NULS_SQLVL        SQLVL_QUEUE
  2721. #define MI_NULZ_SQLVL        SQLVL_QUEUE
  2722. #define    MI_PASS_SQLVL        SQLVL_QUEUE
  2723. #define    MI_PIPEMOD_SQLVL    SQLVL_QUEUE
  2724.  
  2725. #define    MI_SAD_SQLVL        SQLVL_MODULE
  2726. #define    MI_SC_SQLVL            SQLVL_QUEUE
  2727. #define    MI_SOCKMOD_SQLVL    SQLVL_QUEUEPAIR
  2728. #define    MI_SPASS_SQLVL        SQLVL_QUEUE
  2729. #define    MI_SPX_SQLVL        SQLVL_QUEUE
  2730. #define MI_TCP_SQLVL        SQLVL_QUEUEPAIR
  2731. #define MI_TCPM_SQLVL        SQLVL_QUEUEPAIR
  2732. #define MI_TIMOD_SQLVL        SQLVL_QUEUEPAIR
  2733. #define MI_TIRDWR_SQLVL        SQLVL_QUEUE
  2734. #define    MI_TMOD_SQLVL        SQLVL_QUEUEPAIR
  2735. #define    MI_TMUX_SQLVL        SQLVL_MODULE
  2736. #define    MI_TPIT_SQLVL        SQLVL_MODULE
  2737. #define    MI_TRSR_SQLVL        SQLVL_MODULE
  2738. #define    MI_TRXR_SQLVL        SQLVL_QUEUE
  2739. #define MI_UDP_SQLVL        SQLVL_QUEUE
  2740. #define MI_UDPM_SQLVL        SQLVL_QUEUE
  2741. #define    MI_XDG_SQLVL        SQLVL_QUEUE
  2742. #define    MI_XECHO_SQLVL        SQLVL_QUEUE
  2743. #define    MI_XF_SQLVL            SQLVL_MODULE
  2744. #define    MI_XFIPX_SQLVL        SQLVL_MODULE
  2745. #define    MI_XFXNS_SQLVL        SQLVL_MODULE
  2746. #define    MI_XPE_SQLVL        SQLVL_QUEUE
  2747. #define    MI_XS_SQLVL            SQLVL_QUEUEPAIR
  2748. #define    MI_XTINDG_SQLVL        SQLVL_QUEUEPAIR
  2749. #define    MI_XTINVC_SQLVL        SQLVL_QUEUEPAIR
  2750. #define    MI_XTM_SQLVL        SQLVL_QUEUEPAIR
  2751. #define    MI_XTMIP_SQLVL        SQLVL_QUEUEPAIR
  2752. /* ***** Raw Streams ******/
  2753.  
  2754.  
  2755. /*
  2756.    Flags used in the fType field of OTReadInfo for functions.
  2757.    I've removed the terse and confusing comments in this header
  2758.    file.  For a full description, read "Open Transport Advanced
  2759.    Client Programming".
  2760. */
  2761.  
  2762. enum {
  2763.     kOTNoMessagesAvailable        = 0xFFFFFFFF,
  2764.     kOTAnyMsgType                = 0xFFFFFFFE,
  2765.     kOTDataMsgTypes                = 0xFFFFFFFC,
  2766.     kOTMProtoMsgTypes            = 0xFFFFFFFB,
  2767.     kOTOnlyMProtoMsgTypes        = 0xFFFFFFFA
  2768. };
  2769.  
  2770. #if !OTKERNEL
  2771. /* StreamRef is an opaque reference to a raw stream.*/
  2772.  
  2773. typedef struct OpaqueStreamRef*         StreamRef;
  2774. #define kOTInvalidStreamRef ((StreamRef)0L)
  2775. /* PollRef structure is used with the OTStreamPoll function.*/
  2776.  
  2777. struct PollRef {
  2778.     SInt32                             filler;                        /* holds a file descriptor an a UNIX system, replaced by ref (at end of structure) under OT*/
  2779.     SInt16                             events;
  2780.     SInt16                             revents;
  2781.     StreamRef                         ref;
  2782. };
  2783. typedef struct PollRef                    PollRef;
  2784. /* OTReadInfo structure is used with the various functions that read and peek at the stream head.*/
  2785.  
  2786. struct OTReadInfo {
  2787.     UInt32                             fType;
  2788.     OTCommand                         fCommand;
  2789.     UInt32                             fFiller;                    /* For compatibility with OT 1.0 and 1.1 */
  2790.     ByteCount                         fBytes;
  2791.     OSStatus                         fError;
  2792. };
  2793. typedef struct OTReadInfo                OTReadInfo;
  2794. /* Opening and closing raw streams*/
  2795. EXTERN_API( StreamRef )
  2796. OTStreamOpen                    (const char *            name,
  2797.                                  OTOpenFlags             oFlags,
  2798.                                  OSStatus *                errPtr);
  2799.  
  2800. EXTERN_API( OSStatus )
  2801. OTAsyncStreamOpen                (const char *            name,
  2802.                                  OTOpenFlags             oFlags,
  2803.                                  OTNotifyUPP             proc,
  2804.                                  void *                    contextPtr);
  2805.  
  2806. EXTERN_API( StreamRef )
  2807. OTCreateStream                    (OTConfigurationRef     cfig,
  2808.                                  OTOpenFlags             oFlags,
  2809.                                  OSStatus *                errPtr);
  2810.  
  2811. EXTERN_API( OSStatus )
  2812. OTAsyncCreateStream                (OTConfigurationRef     cfig,
  2813.                                  OTOpenFlags             oFlags,
  2814.                                  OTNotifyUPP             proc,
  2815.                                  void *                    contextPtr);
  2816.  
  2817. EXTERN_API( OSStatus )
  2818. OTStreamClose                    (StreamRef                 strm);
  2819.  
  2820. /* Polling a stream for activity*/
  2821.  
  2822. EXTERN_API( OTResult )
  2823. OTStreamPoll                    (PollRef *                fds,
  2824.                                  UInt32                 nfds,
  2825.                                  OTTimeout                 timeout);
  2826.  
  2827. EXTERN_API( OTResult )
  2828. OTAsyncStreamPoll                (PollRef *                fds,
  2829.                                  UInt32                 nfds,
  2830.                                  OTTimeout                 timeout,
  2831.                                  OTNotifyUPP             proc,
  2832.                                  void *                    contextPtr);
  2833.  
  2834. /* Classic UNIX file descriptor operations*/
  2835.  
  2836. EXTERN_API( OTResult )
  2837. OTStreamRead                    (StreamRef                 strm,
  2838.                                  void *                    buf,
  2839.                                  OTByteCount             len);
  2840.  
  2841. EXTERN_API( OTResult )
  2842. OTStreamWrite                    (StreamRef                 strm,
  2843.                                  void *                    buf,
  2844.                                  OTByteCount             len);
  2845.  
  2846. EXTERN_API( OTResult )
  2847. OTStreamIoctl                    (StreamRef                 strm,
  2848.                                  UInt32                 cmd,
  2849.                                  void *                    data);
  2850.  
  2851. EXTERN_API( OTResult )
  2852. OTStreamPipe                    (StreamRef                 streamsToPipe[]);
  2853.  
  2854. /* there can be only 2!*/
  2855. /* Notifiers and modes of operation*/
  2856. EXTERN_API( OSStatus )
  2857. OTStreamInstallNotifier            (StreamRef                 strm,
  2858.                                  OTNotifyUPP             proc,
  2859.                                  void *                    contextPtr);
  2860.  
  2861. EXTERN_API( void )
  2862. OTStreamRemoveNotifier            (StreamRef                 strm);
  2863.  
  2864. EXTERN_API( OSStatus )
  2865. OTStreamUseSyncIdleEvents        (StreamRef                 strm,
  2866.                                  Boolean                 useEvents);
  2867.  
  2868. EXTERN_API( void )
  2869. OTStreamSetBlocking                (StreamRef                 strm);
  2870.  
  2871. EXTERN_API( void )
  2872. OTStreamSetNonBlocking            (StreamRef                 strm);
  2873.  
  2874. EXTERN_API( Boolean )
  2875. OTStreamIsBlocking                (StreamRef                 strm);
  2876.  
  2877. EXTERN_API( void )
  2878. OTStreamSetSynchronous            (StreamRef                 strm);
  2879.  
  2880. EXTERN_API( void )
  2881. OTStreamSetAsynchronous            (StreamRef                 strm);
  2882.  
  2883. EXTERN_API( Boolean )
  2884. OTStreamIsSynchronous            (StreamRef                 strm);
  2885.  
  2886. /* STREAMS primitives*/
  2887.  
  2888. EXTERN_API( OTResult )
  2889. OTStreamGetMessage                (StreamRef                 strm,
  2890.                                  strbuf *                ctlbuf,
  2891.                                  strbuf *                databuf,
  2892.                                  OTFlags *                flags);
  2893.  
  2894. EXTERN_API( OTResult )
  2895. OTStreamGetPriorityMessage        (StreamRef                 strm,
  2896.                                  strbuf *                ctlbuf,
  2897.                                  strbuf *                databuf,
  2898.                                  OTBand *                band,
  2899.                                  OTFlags *                flags);
  2900.  
  2901. EXTERN_API( OSStatus )
  2902. OTStreamPutMessage                (StreamRef                 strm,
  2903.                                  const strbuf *            ctlbuf,
  2904.                                  const strbuf *            databuf,
  2905.                                  OTFlags                 flags);
  2906.  
  2907. EXTERN_API( OSStatus )
  2908. OTStreamPutPriorityMessage        (StreamRef                 strm,
  2909.                                  const strbuf *            ctlbuf,
  2910.                                  const strbuf *            databuf,
  2911.                                  OTBand                 band,
  2912.                                  OTFlags                 flags);
  2913.  
  2914. /* Miscellaneous stuff*/
  2915.  
  2916. EXTERN_API( void )
  2917. OTStreamSetControlMask            (StreamRef                 strm,
  2918.                                  UInt32                 mask,
  2919.                                  Boolean                 setClear);
  2920.  
  2921. /*
  2922.    Opening endpoints and mappers on a Stream - these calls are synchronous, and may
  2923.    only be used at System Task time. Once the stream has been installed into a provider
  2924.    or endpoint, you should not continue to use STREAMS APIs on it
  2925. */
  2926.  
  2927. EXTERN_API( ProviderRef )
  2928. OTOpenProviderOnStream            (StreamRef                 strm,
  2929.                                  OSStatus *                errPtr);
  2930.  
  2931. EXTERN_API( EndpointRef )
  2932. OTOpenEndpointOnStream            (StreamRef                 strm,
  2933.                                  OSStatus *                errPtr);
  2934.  
  2935. /*
  2936.    To quote an earlier version of this header file:
  2937.    
  2938.           Some functions that should only be used if
  2939.           you really know what you're doing.
  2940. */
  2941.  
  2942. EXTERN_API( StreamRef )
  2943. OTRemoveStreamFromProvider        (ProviderRef             ref);
  2944.  
  2945. EXTERN_API( OSStatus )
  2946. OTPeekMessage                    (StreamRef                 strm,
  2947.                                  OTReadInfo *            readInfo);
  2948.  
  2949. EXTERN_API( OTBuffer *)
  2950. OTReadMessage                    (StreamRef                 strm,
  2951.                                  OTReadInfo *            readInfo);
  2952.  
  2953. EXTERN_API( void )
  2954. OTPutBackBuffer                    (StreamRef                 strm,
  2955.                                  OTBuffer *                buffer);
  2956.  
  2957. EXTERN_API( void )
  2958. OTPutBackPartialBuffer            (StreamRef                 strm,
  2959.                                  OTBufferInfo *            readInfo,
  2960.                                  OTBuffer *                buffer);
  2961.  
  2962. #endif  /* !OTKERNEL */
  2963.  
  2964. #endif  /* CALL_NOT_IN_CARBON */
  2965.  
  2966. /* ***** Port Utilities ******/
  2967. #if !OTKERNEL
  2968. /*
  2969.    These types and routines are used during sophisticated
  2970.    port management.  High-level clients may get involved
  2971.    for things like request a port to be yielding, but typically
  2972.    this stuff is used by protocol infrastructure.
  2973. */
  2974. /*
  2975.    OTPortCloseStruct is used when processing the kOTClosePortRequest
  2976.    and kOTYieldPortRequest events.
  2977. */
  2978.  
  2979.  
  2980. struct OTPortCloseStruct {
  2981.     OTPortRef                         fPortRef;                    /* The port requested to be closed.*/
  2982.     ProviderRef                     fTheProvider;                /* The provider using the port.*/
  2983.     OSStatus                         fDenyReason;                /* Set to a negative number to deny the request*/
  2984. };
  2985. typedef struct OTPortCloseStruct        OTPortCloseStruct;
  2986. /* OTClientList structure is used with the OTYieldPortRequest function.*/
  2987.  
  2988. struct OTClientList {
  2989.     ItemCount                         fNumClients;
  2990.     UInt8                             fBuffer[4];
  2991. };
  2992. typedef struct OTClientList                OTClientList;
  2993. /*
  2994.    Returns a buffer containing all of the clients that refused to yield the port.
  2995.    "size" is the total number of bytes @ buffer, including the fNumClients field.
  2996. */
  2997. EXTERN_API_C( OSStatus )
  2998. OTYieldPortRequest                (ProviderRef             ref,
  2999.                                  OTPortRef                 portRef,
  3000.                                  OTClientList *            buffer,
  3001.                                  OTByteCount             size);
  3002.  
  3003. /* Send a notification to all Open Transport registered clients*/
  3004. EXTERN_API_C( void )
  3005. OTNotifyAllClients                (OTEventCode             code,
  3006.                                  OTResult                 result,
  3007.                                  void *                    cookie);
  3008.  
  3009. /* Determine if "child" is a child port of "parent"*/
  3010. EXTERN_API_C( Boolean )
  3011. OTIsDependentPort                (OTPortRef                 parent,
  3012.                                  OTPortRef                 child);
  3013.  
  3014. #endif  /* !OTKERNEL */
  3015.  
  3016. /* ***** Timers ***** */
  3017. /*
  3018.    STREAMS plug-ins code should not use these timers, instead
  3019.    they should use timer messages, ie mi_timer etc.
  3020. */
  3021.  
  3022. #if !OTKERNEL
  3023.  
  3024. typedef long                             OTTimerTask;
  3025. /*
  3026.    Under Carbon, OTCreateTimerTask takes a client context pointer.  Applications may pass NULL
  3027.    after calling InitOpenTransport(kInitOTForApplicationMask, ...).  Non-applications must always pass a
  3028.    valid client context.
  3029. */
  3030. EXTERN_API( long )
  3031. OTCreateTimerTaskInContext        (OTProcessUPP             upp,
  3032.                                  void *                    arg,
  3033.                                  OTClientContextPtr     clientContext);
  3034.  
  3035. EXTERN_API( OTTimerTask )
  3036. OTCreateTimerTask                (OTProcessUPP             proc,
  3037.                                  void *                    arg);
  3038.  
  3039. EXTERN_API( Boolean )
  3040. OTCancelTimerTask                (OTTimerTask             timerTask);
  3041.  
  3042. EXTERN_API( void )
  3043. OTDestroyTimerTask                (OTTimerTask             timerTask);
  3044.  
  3045. EXTERN_API( Boolean )
  3046. OTScheduleTimerTask                (OTTimerTask             timerTask,
  3047.                                  OTTimeout                 milliSeconds);
  3048.  
  3049. #if OTCARBONAPPLICATION
  3050. /* The following macro may be used by applications only.*/
  3051. #define OTCreateTimerTask(upp, arg) OTCreateTimerTaskInContext(upp, arg, NULL)
  3052. #endif  /* OTCARBONAPPLICATION */
  3053.  
  3054. #endif  /* !OTKERNEL */
  3055.  
  3056. /* ***** Miscellaneous Helpful Functions ******/
  3057.  
  3058. #if !OTKERNEL
  3059. /*
  3060.    These routines allow you to manipulate OT's buffer structures.
  3061.    If you use no-copy receives (described in "OpenTransport.h")
  3062.    you will need some of these routines, and may choose to use others.
  3063.    See "Open Tranport Advanced Client Programming" for documentation.
  3064. */
  3065. EXTERN_API_C( OTByteCount )
  3066. OTBufferDataSize                (OTBuffer *                buffer);
  3067.  
  3068. EXTERN_API_C( Boolean )
  3069. OTReadBuffer                    (OTBufferInfo *            buffer,
  3070.                                  void *                    dest,
  3071.                                  OTByteCount *            len);
  3072.  
  3073. EXTERN_API_C( void )
  3074. OTReleaseBuffer                    (OTBuffer *                buffer);
  3075.  
  3076.  
  3077. EXTERN_API_C( Boolean )
  3078. StoreIntoNetbuf                    (TNetbuf *                netBuf,
  3079.                                  void *                    source,
  3080.                                  SInt32                 len);
  3081.  
  3082. EXTERN_API_C( Boolean )
  3083. StoreMsgIntoNetbuf                (TNetbuf *                netBuf,
  3084.                                  OTBuffer *                buffer);
  3085.  
  3086. #endif  /* !OTKERNEL */
  3087.  
  3088. /* ***** OTConfiguration ******/
  3089. #if CALL_NOT_IN_CARBON
  3090. #if !OTKERNEL
  3091. /*
  3092.    As promised in "OpenTransport.h", here are the routines
  3093.    for advanced operations on configurations.
  3094. */
  3095. /* Manipulating a configuration*/
  3096.  
  3097. EXTERN_API_C( OTConfigurationRef )
  3098. OTCfigNewConfiguration            (const char *            path);
  3099.  
  3100. EXTERN_API_C( void )
  3101. OTCfigDeleteConfiguration        (OTConfigurationRef     cfig);
  3102.  
  3103. EXTERN_API_C( OTConfigurationRef )
  3104. OTCfigCloneConfiguration        (OTConfigurationRef     cfig);
  3105.  
  3106. EXTERN_API_C( OTConfigurationRef )
  3107. OTCfigPushNewSingleChild        (OTConfigurationRef     cfig,
  3108.                                  const char *            path,
  3109.                                  OSStatus *                errPtr);
  3110.  
  3111. EXTERN_API_C( OTConfigurationRef )
  3112. OTCfigPushParent                (OTConfigurationRef     cfig,
  3113.                                  const char *            path,
  3114.                                  OSStatus *                errPtr);
  3115.  
  3116. EXTERN_API_C( OTConfigurationRef )
  3117. OTCfigPushChild                    (OTConfigurationRef     cfig,
  3118.                                  OTItemCount             index,
  3119.                                  const char *            path,
  3120.                                  OSStatus *                errPtr);
  3121.  
  3122. EXTERN_API_C( OSStatus )
  3123. OTCfigPopChild                    (OTConfigurationRef     cfig,
  3124.                                  OTItemCount             index);
  3125.  
  3126. EXTERN_API_C( OTConfigurationRef )
  3127. OTCfigGetChild                    (OTConfigurationRef     cfig,
  3128.                                  OTItemCount             index);
  3129.  
  3130. EXTERN_API_C( OSStatus )
  3131. OTCfigSetPath                    (OTConfigurationRef     cfig,
  3132.                                  const char *            path);
  3133.  
  3134. EXTERN_API_C( OTConfigurationRef )
  3135. OTCfigNewChild                    (OTConfigurationRef     cfig,
  3136.                                  const char *            path,
  3137.                                  OSStatus *                errPtr);
  3138.  
  3139. EXTERN_API_C( OSStatus )
  3140. OTCfigAddChild                    (OTConfigurationRef     cfig,
  3141.                                  OTConfigurationRef     child);
  3142.  
  3143. EXTERN_API_C( OTConfigurationRef )
  3144. OTCfigRemoveChild                (OTConfigurationRef     cfig,
  3145.                                  OTItemCount             index);
  3146.  
  3147. EXTERN_API_C( void )
  3148. OTCfigSetPortRef                (OTConfigurationRef     cfig,
  3149.                                  OTPortRef                 portRef);
  3150.  
  3151. EXTERN_API_C( void )
  3152. OTCfigChangeProviderName        (OTConfigurationRef     cfig,
  3153.                                  const char *            name);
  3154.  
  3155. /* Query a configuration*/
  3156.  
  3157. EXTERN_API_C( UInt16 )
  3158. OTCfigNumberOfChildren            (OTConfigurationRef     cfig);
  3159.  
  3160. EXTERN_API_C( OTConfigurationRef )
  3161. OTCfigGetParent                    (OTConfigurationRef     cfig);
  3162.  
  3163. EXTERN_API_C( TNetbuf *)
  3164. OTCfigGetOptionNetbuf            (OTConfigurationRef     cfig);
  3165.  
  3166. EXTERN_API_C( OTPortRef )
  3167. OTCfigGetPortRef                (OTConfigurationRef     cfig);
  3168.  
  3169. EXTERN_API_C( UInt32 )
  3170. OTCfigGetInstallFlags            (OTConfigurationRef     cfig);
  3171.  
  3172. EXTERN_API_C( const char *)
  3173. OTCfigGetProviderName            (OTConfigurationRef     cfig);
  3174.  
  3175. EXTERN_API_C( Boolean )
  3176. OTCfigIsPort                    (OTConfigurationRef     cfig);
  3177.  
  3178. #endif  /* !OTKERNEL */
  3179.  
  3180. /* ***** Configurators ******/
  3181. /*
  3182.    The kOTConfiguratorInterfaceID define is what you need to add to your
  3183.    export file for the "interfaceID = " clause to export a configurator
  3184.    for ASLM.  Similarly, kOTConfiguratorCFMTag is used for CFM-based
  3185.    configurators.
  3186. */
  3187.  
  3188.  
  3189. #define kOTConfiguratorInterfaceID    kOTClientPrefix "cfigMkr"
  3190. #define kOTConfiguratorCFMTag        kOTClientPrefix "cfigMkr"
  3191.  
  3192. #if !OTKERNEL
  3193. #ifdef __cplusplus
  3194.     class TOTConfigurator;
  3195.     typedef class TOTConfigurator* TOTConfiguratorRef;
  3196. #else
  3197.     typedef struct TOTConfigurator TOTConfigurator;
  3198.     typedef TOTConfigurator* TOTConfiguratorRef;
  3199. #endif
  3200. /*
  3201.    Typedef for the OTCanConfigure function, and the enum for which pass we're doing.
  3202.    The first (kOTSpecificConfigPass) is to give configurators a shot at the configuration
  3203.    before we start allowing the generic configurators to get into the act.
  3204. */
  3205. enum {
  3206.     kOTSpecificConfigPass        = 0,
  3207.     kOTGenericConfigPass        = 1
  3208. };
  3209.  
  3210. typedef CALLBACK_API_C( Boolean , OTCanConfigureProcPtr )(OTConfigurationRef cfig, UInt32 pass);
  3211. /* Typedef for the function to create and return a configurator object*/
  3212. typedef CALLBACK_API_C( OSStatus , OTCreateConfiguratorProcPtr )(TOTConfiguratorRef *cfigor);
  3213. /*
  3214.    Typedef for the "OTSetupConfigurator" function that your configurator library must export.
  3215.    The enum is for the type of configurator that it is.
  3216. */
  3217. #define kOTSetupConfiguratorID "OTSetupConfigurator"
  3218. enum {
  3219.     kOTDefaultConfigurator        = 0,
  3220.     kOTProtocolFamilyConfigurator = 1,
  3221.     kOTLinkDriverConfigurator    = 2
  3222. };
  3223.  
  3224. typedef CALLBACK_API_C( OSStatus , OTSetupConfiguratorProcPtr )(OTCanConfigureProcPtr *canConfigure, OTCreateConfiguratorProcPtr *createConfigurator, UInt8 *configuratorType);
  3225. /*
  3226.    Procedure pointer definitions for the three key callbacks associated
  3227.    with a configurator, as established by OTNewConfigurator.
  3228. */
  3229. typedef CALLBACK_API_C( OSStatus , OTCFConfigureProcPtr )(TOTConfiguratorRef cfigor, OTConfigurationRef cfig);
  3230. typedef CALLBACK_API_C( OSStatus , OTCFCreateStreamProcPtr )(TOTConfiguratorRef cfigor, OTConfigurationRef cfig, OTOpenFlags oFlags, OTNotifyUPP proc, void *contextPtr);
  3231. typedef CALLBACK_API_C( void , OTCFHandleSystemEventProcPtr )(TOTConfiguratorRef cfigor, OTEventCode code, OTResult result, void *cookie);
  3232. /*
  3233.    Determine if this instance of your configurator is the "master"
  3234.    (the one that can create and destroy control streams)
  3235. */
  3236. EXTERN_API_C( Boolean )
  3237. OTIsMasterConfigurator            (TOTConfiguratorRef     cfigor);
  3238.  
  3239. /* Get back the userData you passed in to OTNewConfigurator*/
  3240. EXTERN_API_C( void *)
  3241. OTGetConfiguratorUserData        (TOTConfiguratorRef     cfigor);
  3242.  
  3243. /* Create a configurator object for use by Open Transport*/
  3244. EXTERN_API_C( TOTConfiguratorRef )
  3245. OTNewConfigurator                (void *                    userData,
  3246.                                  OTCFConfigureProcPtr     configure,
  3247.                                  OTCFCreateStreamProcPtr  createStream,
  3248.                                  OTCFHandleSystemEventProcPtr  handleEvent);
  3249.  
  3250. /* Delete a configurator object created by OTNewConfigurator*/
  3251. EXTERN_API_C( void )
  3252. OTDeleteConfigurator            (TOTConfiguratorRef     cfigor);
  3253.  
  3254. /*
  3255.    A utility function to send notifications to the user - it takes care of calls
  3256.    from deferred tasks
  3257. */
  3258. EXTERN_API_C( OSStatus )
  3259. OTNotifyUser                    (FSSpec *                theFile,
  3260.                                  SInt32                 rsrcID,
  3261.                                  OTItemCount             index,
  3262.                                  char *                    parm1,
  3263.                                  char *                    parm2);
  3264.  
  3265. /* Call when the configurator unloads from memory*/
  3266. EXTERN_API_C( void )
  3267. OTConfiguratorUnloaded            (TOTConfiguratorRef     cfigor);
  3268.  
  3269. /*
  3270.    Call to create your control stream if you're not the master
  3271.    configurator.  You can also use the state machine function
  3272.    OTSMCreateControlStream(OTStateMachine*, OTConfigurationRef, TOTConfiguratorRef cfigor).
  3273. */
  3274. EXTERN_API_C( OSStatus )
  3275. OTCreateControlStream            (OTConfigurationRef     cfig,
  3276.                                  TOTConfiguratorRef     cfigor,
  3277.                                  OTNotifyUPP             proc,
  3278.                                  void *                    contextPtr);
  3279.  
  3280. /*
  3281.    A helpful function for the configurators to
  3282.    be able to recursively configure the children.
  3283. */
  3284. EXTERN_API_C( OSStatus )
  3285. OTConfigureChildren                (OTConfigurationRef     cfig);
  3286.  
  3287. /* Allocate a bit in the system-wide control mask for streams.*/
  3288. EXTERN_API_C( UInt32 )
  3289. OTNewControlMask                (void);
  3290.  
  3291. /* Warning: These 2 APIs is going away*/
  3292. EXTERN_API_C( void )
  3293. OTCloseProvidersByUseCount        (SInt32 *                useCount,
  3294.                                  OTResult                 reason,
  3295.                                  OTBooleanParam         doneDeal);
  3296.  
  3297. EXTERN_API_C( void )
  3298. OTCloseProvidersByPortRef        (OTPortRef                 ref,
  3299.                                  OTResult                 reason,
  3300.                                  OTBooleanParam         doneDeal);
  3301.  
  3302. /* These are the "real" APIs*/
  3303. EXTERN_API_C( void )
  3304. OTCloseProviderByStream            (StreamRef                 ref,
  3305.                                  OTResult                 reason,
  3306.                                  OTBooleanParam         doneDeal);
  3307.  
  3308. EXTERN_API_C( void )
  3309. OTCloseMatchingProviders        (UInt32                 mask,
  3310.                                  OTPortRef                 port,
  3311.                                  OTResult                 reason,
  3312.                                  OTBooleanParam         doneDeal);
  3313.  
  3314. #endif  /* !OTKERNEL */
  3315.  
  3316. #endif  /* CALL_NOT_IN_CARBON */
  3317.  
  3318. /* ***** OTStateMachine ******/
  3319. #if CALL_NOT_IN_CARBON
  3320. /*
  3321.    This utility set allows you to write an asynchronous chain of code that looks 
  3322.    somewhat like it is synchronous.  This is primarily used for plumbing 
  3323.    streams asynchronously, especially in configurators
  3324. */
  3325. #if !OTKERNEL
  3326. /* Alas, the state machine is only available to client code.  Sorry.*/
  3327.  
  3328. /*
  3329.    There are 12 or 8 bytes of reserved space at the front of
  3330.    the OTStateMachine structure, depending on whether you're
  3331.    building PowerPC or 68K code..  The OTStateMachineDataPad
  3332.    type compensates for this.
  3333. */
  3334.  
  3335. #if TARGET_CPU_PPC
  3336. typedef UInt8                             OTStateMachineDataPad[12];
  3337. #else
  3338. typedef UInt8                             OTStateMachineDataPad[8];
  3339. #endif  /* TARGET_CPU_PPC */
  3340.  
  3341. /*
  3342.    Forward define OTStateMachine so that OTStateProcPtr has
  3343.    access to it.
  3344. */
  3345. typedef struct OTStateMachine             OTStateMachine;
  3346. /*
  3347.    This type is is the required prototype of a state machine
  3348.    entry point.
  3349. */
  3350. typedef CALLBACK_API( void , OTStateProcPtr )(OTStateMachine *sm);
  3351. /*
  3352.    This type defines a routine that the state machine will
  3353.    call when the top level completes.
  3354. */
  3355. typedef CALLBACK_API_C( void , OTSMCompleteProcPtr )(void *contextPtr);
  3356. /* And now for the state machine structure itself.*/
  3357.  
  3358. struct OTStateMachine {
  3359.     OTStateMachineDataPad             fData;
  3360.     void *                            fCookie;
  3361.     OTEventCode                     fCode;
  3362.     OTResult                         fResult;
  3363. #ifdef __cplusplus
  3364.  
  3365.     // C++ inline methods on this structure.
  3366.  
  3367.  
  3368.  
  3369.     void*        GetClientData();
  3370.  
  3371.     Boolean        CallStateProc(OTStateProcPtr proc, UInt32 state = 0);
  3372.  
  3373.     UInt16        GetState();
  3374.  
  3375.     void        SetState(UInt32 state);
  3376.  
  3377.     void        Complete();
  3378.  
  3379.     void        Complete(OTResult result);
  3380.  
  3381.     void        Complete(OTResult result, OTEventCode code, void* contextPtr);
  3382.  
  3383.     void        CompleteToClient();
  3384.  
  3385.     void        CompleteToClient(OTResult result);
  3386.  
  3387.     void        CompleteToClient(OTResult result, OTEventCode code, void* contexPtr);
  3388.  
  3389.     void        PopCallback();
  3390.  
  3391.     Boolean        CreateStream(OTConfigurationRef cfig, OTOpenFlags flags);
  3392.  
  3393.     Boolean        OpenStream(const char* name, OTOpenFlags flags);
  3394.  
  3395.     Boolean        SendIoctl(StreamRef ref, UInt32 type, void* data);
  3396.  
  3397.     Boolean        SendIoctl(StreamRef ref, UInt32 type, long data);
  3398.  
  3399.     Boolean        PutMessage(StreamRef ref, strbuf* ctl, strbuf* data, OTFlags flags);
  3400.  
  3401.     Boolean        GetMessage(StreamRef ref, strbuf* ctl, strbuf* data, OTFlags* flagPtr);
  3402.  
  3403.     OSStatus    ReturnToCaller();
  3404.  
  3405. #endif
  3406.  
  3407. };
  3408.  
  3409. #define kOTSMBufferSize(callDepth) (80 + (callDepth * 8))
  3410. /*
  3411.    For structSize, pass the size of your structure that you want associated with
  3412.    the state machine.  It can later be obtained by calling OTSMGetClientData.
  3413.    For bufSize, use the kOTSMBufferSize macro, plus the size of your structure
  3414.    to create a buffer on the stack. For synchronous calls, the stack buffer will
  3415.    be used (unless you pass in NULL).  The callDepth is the depth level of nested
  3416.    calls using OTSMCallStateProc.
  3417. */
  3418. EXTERN_API_C( OTStateMachine *)
  3419. OTCreateStateMachine            (void *                    buf,
  3420.                                  OTByteCount             bufSize,
  3421.                                  OTByteCount             structSize,
  3422.                                  OTNotifyUPP             proc,
  3423.                                  void *                    contextPtr);
  3424.  
  3425. EXTERN_API_C( void )
  3426. OTDestroyStateMachine            (OTStateMachine *        sm);
  3427.  
  3428. /*
  3429.    OTSMCallStateProc used to take a parameter of type UInt16_p,
  3430.    which was defined to be the same as UInt32.  In an attempt
  3431.    to reduce the number of wacky types defined by the OT
  3432.    interfaces, we've changed these routines to just take a
  3433.    straight UInt32.  You should be warned that the current
  3434.    implementation does not support values outside of the
  3435.    range 0..32767.  The same applies to OTSMSetState.
  3436. */
  3437.  
  3438. EXTERN_API_C( Boolean )
  3439. OTSMCallStateProc                (OTStateMachine *        sm,
  3440.                                  OTStateProcPtr         proc,
  3441.                                  UInt32                 state);
  3442.  
  3443. EXTERN_API_C( UInt16 )
  3444. OTSMGetState                    (OTStateMachine *        sm);
  3445.  
  3446. EXTERN_API_C( void )
  3447. OTSMSetState                    (OTStateMachine *        sm,
  3448.                                  UInt32                 state);
  3449.  
  3450. /* Fill out the fCookie, fCode, and fResult fields before calling!*/
  3451. EXTERN_API_C( void )
  3452. OTSMComplete                    (OTStateMachine *        sm);
  3453.  
  3454. EXTERN_API_C( void )
  3455. OTSMPopCallback                    (OTStateMachine *        sm);
  3456.  
  3457. EXTERN_API_C( Boolean )
  3458. OTSMWaitForComplete                (OTStateMachine *        sm);
  3459.  
  3460. EXTERN_API_C( Boolean )
  3461. OTSMCreateStream                (OTStateMachine *        sm,
  3462.                                  OTConfigurationRef     cfig,
  3463.                                  OTOpenFlags             flags);
  3464.  
  3465. EXTERN_API_C( Boolean )
  3466. OTSMOpenStream                    (OTStateMachine *        sm,
  3467.                                  const char *            name,
  3468.                                  OTOpenFlags             flags);
  3469.  
  3470. EXTERN_API_C( Boolean )
  3471. OTSMIoctl                        (OTStateMachine *        sm,
  3472.                                  StreamRef                 strm,
  3473.                                  UInt32                 cmd,
  3474.                                  long                     data);
  3475.  
  3476. EXTERN_API_C( Boolean )
  3477. OTSMPutMessage                    (OTStateMachine *        sm,
  3478.                                  StreamRef                 strm,
  3479.                                  strbuf *                ctlbuf,
  3480.                                  strbuf *                databuf,
  3481.                                  OTFlags                 flags);
  3482.  
  3483. EXTERN_API_C( Boolean )
  3484. OTSMGetMessage                    (OTStateMachine *        sm,
  3485.                                  StreamRef                 strm,
  3486.                                  strbuf *                ctlbuf,
  3487.                                  strbuf *                databuf,
  3488.                                  OTFlags *                flagsPtr);
  3489.  
  3490. EXTERN_API_C( OSStatus )
  3491. OTSMReturnToCaller                (OTStateMachine *        sm);
  3492.  
  3493. EXTERN_API_C( void *)
  3494. OTSMGetClientData                (OTStateMachine *        sm);
  3495.  
  3496. EXTERN_API_C( void )
  3497. OTSMInstallCompletionProc        (OTStateMachine *        sm,
  3498.                                  OTSMCompleteProcPtr     completeProc,
  3499.                                  void *                    contextPtr);
  3500.  
  3501. EXTERN_API_C( Boolean )
  3502. OTSMCreateControlStream            (OTStateMachine *        sm,
  3503.                                  OTConfigurationRef     cfig,
  3504.                                  TOTConfiguratorRef     cfigor);
  3505.  
  3506.  
  3507. #ifdef __cplusplus
  3508.     inline void*        OTStateMachine::GetClientData()    { return OTSMGetClientData(this); }
  3509.     inline Boolean        OTStateMachine::CallStateProc(OTStateProcPtr proc, UInt32 state)
  3510.                                                         { return OTSMCallStateProc(this, proc, state); }
  3511.     inline UInt16        OTStateMachine::GetState()        { return OTSMGetState(this); }
  3512.     inline void            OTStateMachine::SetState(UInt32 state)
  3513.                                                         { OTSMSetState(this, state); }
  3514.     inline void            OTStateMachine::PopCallback()    { OTSMPopCallback(this); }
  3515.     inline void            OTStateMachine::Complete()        { OTSMComplete(this); }
  3516.     inline void         OTStateMachine::Complete(OTResult result, OTEventCode code, void* cookie)
  3517.                                                          { fCookie = cookie; fCode = code; fResult = result; Complete(); }
  3518.     inline void         OTStateMachine::Complete(OTResult result)
  3519.                                                         { fResult = result; Complete(); }
  3520.     inline void         OTStateMachine::CompleteToClient()
  3521.                                                         { PopCallback(); Complete(); }
  3522.     inline void         OTStateMachine::CompleteToClient(OTResult result)
  3523.                                                         { fResult    = result; CompleteToClient(); }
  3524.     
  3525.     inline void         OTStateMachine::CompleteToClient(OTResult result, OTEventCode code, void* cookie)
  3526.                                                         { fCookie = cookie; fCode = code; fResult = result; CompleteToClient(); }
  3527.     inline Boolean        OTStateMachine::CreateStream(OTConfigurationRef cfig, OTOpenFlags flags)
  3528.                                                         { return OTSMCreateStream(this, cfig, flags); }
  3529.     inline Boolean        OTStateMachine::OpenStream(const char* name, OTOpenFlags flags)
  3530.                                                         { return OTSMOpenStream(this, name, flags); }
  3531.     inline Boolean        OTStateMachine::SendIoctl(StreamRef ref, UInt32 type, void* data)
  3532.                                                         { return OTSMIoctl(this, ref, type, (long)data); }
  3533.     inline Boolean        OTStateMachine::SendIoctl(StreamRef ref, UInt32 type, long data)
  3534.                                                         { return OTSMIoctl(this, ref, type, data); }
  3535.     inline Boolean        OTStateMachine::PutMessage(StreamRef ref, struct strbuf* ctl, struct strbuf* data, OTFlags flags)
  3536.                                                         { return OTSMPutMessage(this, ref, ctl, data, flags); }
  3537.     inline Boolean        OTStateMachine::GetMessage(StreamRef ref, struct strbuf* ctl, struct strbuf* data, OTFlags* flagPtr)
  3538.                                                         { return OTSMGetMessage(this, ref, ctl, data, flagPtr); }
  3539.     inline OSStatus        OTStateMachine::ReturnToCaller()
  3540.                                                         { return OTSMReturnToCaller(this); }
  3541. #endif
  3542.  
  3543. #endif  /* !OTKERNEL */
  3544.  
  3545. /* ***** Autopush Definitions ******/
  3546. /*
  3547.    The autopush functionality for Open Transport is based on the names of
  3548.    devices and modules, rather than on the major number information like 
  3549.    SVR4.  This is so that autopush information can be set up for modules
  3550.    that are not yet loaded.
  3551. */
  3552.  
  3553.  
  3554. /* The name of the STREAMS driver you open and send the ioctls to.*/
  3555. #define kSADModuleName    "sad"
  3556. /* Autopush ioctls.*/
  3557. enum {
  3558.     I_SAD_SAP                    = ((MIOC_SAD << 8) | 1),        /* Set autopush information        */
  3559.     I_SAD_GAP                    = ((MIOC_SAD << 8) | 2),        /* Get autopush information        */
  3560.     I_SAD_VML                    = ((MIOC_SAD << 8) | 3)            /* Validate a list of modules (uses str_list structure) */
  3561. };
  3562.  
  3563. /* Maximum number of modules autopushed on a driver.*/
  3564.  
  3565. enum {
  3566.     kOTAutopushMax                = 8
  3567. };
  3568.  
  3569.  
  3570. /* ioctl structure used for SAD_SAP and SAD_GAP commands.*/
  3571.  
  3572.  
  3573. struct OTAutopushInfo {
  3574.     UInt32                             sap_cmd;
  3575.     char                             sap_device_name[32];
  3576.     SInt32                             sap_minor;
  3577.     SInt32                             sap_lastminor;
  3578.     SInt32                             sap_npush;
  3579.     char                             sap_list[8][32];
  3580. };
  3581. typedef struct OTAutopushInfo            OTAutopushInfo;
  3582. /* Command values for sap_cmd field of the above.*/
  3583. enum {
  3584.     kSAP_ONE                    = 1,                            /* Configure a single minor device            */
  3585.     kSAP_RANGE                    = 2,                            /* Configure a range of minor devices        */
  3586.     kSAP_ALL                    = 3,                            /* Configure all minor devices                */
  3587.     kSAP_CLEAR                    = 4                                /* Clear autopush information                */
  3588. };
  3589.  
  3590.  
  3591. /* ***** Configuration Helpers ******/
  3592.  
  3593. /*
  3594.    These definitions are used by device driver and port scanner
  3595.    developers to provide a library giving client-side information about
  3596.    the registered ports, such as a user-visible name or an icon.
  3597. */
  3598.  
  3599. /* Configuration helper library prefix*/
  3600.  
  3601. /*
  3602.    This prefix is prepended to the string found in the "fResourceInfo"
  3603.    field of the OTPortRecord to build the actual library name of the
  3604.    configuration helper library.
  3605. */
  3606.  
  3607. #define kPortConfigLibPrefix "OTPortCfg$"
  3608.  
  3609. /* Get user visible port name entry point.*/
  3610.  
  3611. /*
  3612.    This entry point returns the user visible name of the port.  If includeSlot
  3613.    is true, a slot distinguishing suffix (eg "slot X") should be added.  If
  3614.    includePort is true, a port distinguishing suffix (eg " port X") should be added for
  3615.    multiport cards.
  3616. */
  3617.  
  3618. #define kOTGetUserPortNameID "OTGetUserPortName"
  3619. typedef CALLBACK_API_C( void , OTGetPortNameProcPtr )(OTPortRecord *port, OTBooleanParam includeSlot, OTBooleanParam includePort, Str255 userVisibleName);
  3620. /* Get icon entry point.*/
  3621. /*
  3622.    This entry point returns the location of the icon for the port.  Return false if no
  3623.    icon is provided.
  3624. */
  3625.  
  3626. #define kOTGetPortIconID "OTGetPortIcon"
  3627.  
  3628. struct OTResourceLocator {
  3629.     FSSpec                             fFile;
  3630.     UInt16                             fResID;
  3631. };
  3632. typedef struct OTResourceLocator        OTResourceLocator;
  3633. typedef CALLBACK_API_C( Boolean , OTGetPortIconProcPtr )(OTPortRecord *port, OTResourceLocator *iconLocation);
  3634. /* ***** Application Access to Configuration Helpers ******/
  3635.  
  3636. #if !OTKERNEL
  3637. /*
  3638.    These routines are used by clients to get information about ports.
  3639.    The canonical user of these routines is the OT control panel(s),
  3640.    but applications may want to use them as well (to display the list
  3641.    of available Ethernet cards, for example).
  3642. */
  3643. /*    Returns a user friendly name for a port.*/
  3644. EXTERN_API_C( void )
  3645. OTGetUserPortNameFromPortRef    (OTPortRef                 ref,
  3646.                                  Str255                 friendlyName);
  3647.  
  3648. /*
  3649.       Returns the location for the icon familly representing the port.
  3650.       Returns false if the port has no icon.
  3651. */
  3652. EXTERN_API_C( Boolean )
  3653. OTGetPortIconFromPortRef        (OTPortRef                 ref,
  3654.                                  OTResourceLocator *    iconLocation);
  3655.  
  3656. /* Returns true if the port can be used with the specified protocol.*/
  3657. EXTERN_API_C( Boolean )
  3658. OTIsPortCompatibleWith            (const OTPortRecord *    port,
  3659.                                  char *                    protocolName);
  3660.  
  3661. #endif  /* !OTKERNEL */
  3662.  
  3663. #endif  /* CALL_NOT_IN_CARBON */
  3664.  
  3665. /* ***** Common Utilities ******/
  3666. /*
  3667.    The utilities defined in this section are available to both client
  3668.    and kernel code.  Cool huh?  These utilities differ from those
  3669.    provided in "OpenTransport.h" in that they are only available to native
  3670.    architecture clients.
  3671. */
  3672.  
  3673. /* Bitmap functions*/
  3674.  
  3675. /* These functions atomically deal with a bitmap that is multiple-bytes long*/
  3676.  
  3677. /*
  3678.    Set the first clear bit in "bitMap", starting with bit "startBit",
  3679.    giving up after "numBits".  Returns the bit # that was set, or
  3680.    a kOTNotFoundErr if there was no clear bit available
  3681. */
  3682. EXTERN_API_C( OTResult )
  3683. OTSetFirstClearBit                (UInt8 *                bitMap,
  3684.                                  OTByteCount             startBit,
  3685.                                  OTByteCount             numBits);
  3686.  
  3687. /* Standard clear, set and test bit functions*/
  3688. EXTERN_API_C( Boolean )
  3689. OTClearBit                        (UInt8 *                bitMap,
  3690.                                  OTByteCount             bitNo);
  3691.  
  3692. EXTERN_API_C( Boolean )
  3693. OTSetBit                        (UInt8 *                bitMap,
  3694.                                  OTByteCount             bitNo);
  3695.  
  3696. EXTERN_API_C( Boolean )
  3697. OTTestBit                        (UInt8 *                bitMap,
  3698.                                  OTByteCount             bitNo);
  3699.  
  3700. /* OTHashList*/
  3701.  
  3702. /*
  3703.    This implements a simple, but efficient hash list.  It is not
  3704.    thread-safe.
  3705. */
  3706.  
  3707. typedef CALLBACK_API_C( UInt32 , OTHashProcPtr )(OTLink *linkToHash);
  3708. typedef CALLBACK_API_C( Boolean , OTHashSearchProcPtr )(const void *ref, OTLink *linkToCheck);
  3709.  
  3710. struct OTHashList {
  3711.     OTHashProcPtr                     fHashProc;
  3712.     ByteCount                         fHashTableSize;
  3713.     OTLink **                        fHashBuckets;
  3714. #ifdef __cplusplus
  3715.  
  3716.     // C++ inline methods on this structure.
  3717.  
  3718.  
  3719.  
  3720.     void            Add(OTLink* toAdd);
  3721.  
  3722.     Boolean            RemoveLink(OTLink* toRemove);
  3723.  
  3724.     OTLink*            Remove(OTHashSearchProcPtr proc, const void* refPtr, UInt32 hashValue);
  3725.  
  3726.     Boolean            IsInList(OTLink* toFind);
  3727.  
  3728.     OTLink*            FindLink(OTHashSearchProcPtr proc, const void* refPtr, UInt32 hash);
  3729.  
  3730. #endif
  3731.  
  3732. };
  3733. typedef struct OTHashList                OTHashList;
  3734. /*
  3735.    Return the number of bytes of memory needed to create a hash list
  3736.    of at least "numEntries" entries.
  3737. */
  3738. EXTERN_API_C( OTByteCount )
  3739. OTCalculateHashListMemoryNeeds    (OTItemCount             numEntries);
  3740.  
  3741. /*
  3742.    Create an OTHashList from "memory".  Return an error if it
  3743.    couldn't be done.
  3744. */
  3745. EXTERN_API_C( OTResult )
  3746. OTInitHashList                    (void *                    memory,
  3747.                                  OTByteCount             numBytes,
  3748.                                  OTHashProcPtr             hashProc);
  3749.  
  3750. EXTERN_API_C( void )
  3751. OTAddToHashList                    (OTHashList *            hashList,
  3752.                                  OTLink *                linkToAdd);
  3753.  
  3754. EXTERN_API_C( Boolean )
  3755. OTRemoveLinkFromHashList        (OTHashList *            hashList,
  3756.                                  OTLink *                linkToRemove);
  3757.  
  3758. EXTERN_API_C( Boolean )
  3759. OTIsInHashList                    (OTHashList *            hashList,
  3760.                                  OTLink *                link);
  3761.  
  3762. EXTERN_API_C( OTLink *)
  3763. OTFindInHashList                (OTHashList *            hashList,
  3764.                                  OTHashSearchProcPtr     searchProc,
  3765.                                  const void *            refPtr,
  3766.                                  UInt32                 hashValue);
  3767.  
  3768. EXTERN_API_C( OTLink *)
  3769. OTRemoveFromHashList            (OTHashList *            hashList,
  3770.                                  OTHashSearchProcPtr     searchProc,
  3771.                                  const void *            refPtr,
  3772.                                  UInt32                 hashValue);
  3773.  
  3774.  
  3775. #ifdef __cplusplus
  3776.     // C++ inline methods on this structure.
  3777.  
  3778.     inline void            OTHashList::Add(OTLink* toAdd)    { OTAddToHashList(this, toAdd); }
  3779.  
  3780.     inline Boolean        OTHashList::RemoveLink(OTLink* toRemove)
  3781.                                                         { return OTRemoveLinkFromHashList(this, toRemove); }
  3782.     inline OTLink*        OTHashList::Remove(OTHashSearchProcPtr proc, const void* refPtr, UInt32 hashValue)
  3783.                                                         { return OTRemoveFromHashList(this, proc, refPtr, hashValue); }
  3784.     inline Boolean        OTHashList::IsInList(OTLink* toFind)
  3785.                                                         { return OTIsInHashList(this, toFind); }
  3786.     inline OTLink*        OTHashList::FindLink(OTHashSearchProcPtr proc, const void* refPtr, UInt32 hash)
  3787.                                                         { return OTFindInHashList(this, proc, refPtr, hash); }
  3788. #endif
  3789.  
  3790. /* Random functions*/
  3791.  
  3792. /*
  3793.    These implement a very simple random number generator, suitable
  3794.    for protocol implementations but not "cryptographically" random.
  3795. */
  3796.  
  3797. EXTERN_API_C( UInt32 )
  3798. OTGetRandomSeed                    (void);
  3799.  
  3800. EXTERN_API_C( UInt32 )
  3801. OTGetRandomNumber                (UInt32 *                seed,
  3802.                                  UInt32                 lo,
  3803.                                  UInt32                 hi);
  3804.  
  3805. /* Concurrency Control*/
  3806.  
  3807. /*
  3808.    OTGate implements a cool concurrency control primitive.
  3809.    You're not going to understand it without reading the documentation!
  3810.    See "Open Transport Advanced Client Programming" for details.
  3811.    WARNING:
  3812.    This structure must be on a 4-byte boundary.
  3813. */
  3814.  
  3815. typedef CALLBACK_API_C( Boolean , OTGateProcPtr )(OTLink *thisLink);
  3816.  
  3817. struct OTGate {
  3818.     OTLIFO                             fLIFO;
  3819.     OTList                             fList;
  3820.     OTGateProcPtr                     fProc;
  3821.     SInt32                             fNumQueued;
  3822.     SInt32                             fInside;
  3823. };
  3824. typedef struct OTGate                    OTGate;
  3825. EXTERN_API_C( void )
  3826. OTInitGate                        (OTGate *                gate,
  3827.                                  OTGateProcPtr             proc);
  3828.  
  3829. EXTERN_API_C( Boolean )
  3830. OTEnterGate                        (OTGate *                gate,
  3831.                                  OTLink *                withLink);
  3832.  
  3833. EXTERN_API_C( Boolean )
  3834. OTLeaveGate                        (OTGate *                gate);
  3835.  
  3836. /* ***** Shared Library Bonus Extras ******/
  3837.  
  3838. #if CALL_NOT_IN_CARBON
  3839. /*
  3840.    These routines provide addition shared library support beyond
  3841.    that provided by the base shared library mechanism.
  3842. */
  3843. /*
  3844.    Some flags which can be passed to the "loadFlags" parameter of the
  3845.    various CFM routines.  Not all flags can be used with all routines.
  3846.    See "Open Transport Advanced Client Programming" for details.
  3847. */
  3848.  
  3849. enum {
  3850.     kOTGetDataSymbol            = 0,
  3851.     kOTGetCodeSymbol            = 1,
  3852.     kOTLoadNewCopy                = 2,
  3853.     kOTLoadACopy                = 4,
  3854.     kOTFindACopy                = 8,
  3855.     kOTLibMask                    = kOTLoadNewCopy | kOTLoadACopy | kOTFindACopy,
  3856.     kOTLoadLibResident            = 0x20
  3857. };
  3858.  
  3859. /* Finding all matching CFM libraries.*/
  3860.  
  3861. /*
  3862.    The routine OTFindCFMLibraries allows you to find all CFM libraries
  3863.    that match specific criteria.  The result is placed in a list
  3864.    of CFMLibraryInfo structures.  OT allocates those structures using
  3865.    a routine of type OTAllocMemProcPtr that you pass to OTFindCFMLibraries.
  3866. */
  3867.  
  3868. /*
  3869.    A list of CFMLibraryInfo structures is returned by the OTFindCFMLibraries routine.
  3870.    The list is created out of the data that is passed to the function.
  3871.    
  3872.    IMPORTANT:
  3873.    Only the first 3 fields are valid when using OT 1.2 and older.
  3874. */
  3875.  
  3876.  
  3877. struct CFMLibraryInfo {
  3878.     OTLink                             link;                        /* To link them all up on a list                    */
  3879.     char *                            libName;                    /* "C" String which is fragment name                */
  3880.     StringPtr                         intlName;                    /* Pascal String which is internationalized name    */
  3881.     FSSpec *                        fileSpec;                    /* location of fragment's file */
  3882.     StringPtr                         pstring2;                    /* Secondary string from extended cfrg                */
  3883.     StringPtr                         pstring3;                    /* Extra info from extended cfrg                    */
  3884. };
  3885. typedef struct CFMLibraryInfo            CFMLibraryInfo;
  3886. /*
  3887.    You must pass a routine of type OTAllocMemProcPtr to OTFindCFMLibraries
  3888.    which it calls to allocate memory for the CFMLibraryInfo structures.
  3889. */
  3890. typedef CALLBACK_API_C( void *, OTAllocMemProcPtr )(OTByteCount size);
  3891. /* Find CFM libraries of the specified kind and type*/
  3892. EXTERN_API_C( OSStatus )
  3893. OTFindCFMLibraries                (OSType                 libKind,
  3894.                                  const char *            libType,
  3895.                                  OTList *                theList,
  3896.                                  OTAllocMemProcPtr         allocator);
  3897.  
  3898. /* Loading libraries and connecting to symbols.*/
  3899.  
  3900. /* Load a CFM library by name*/
  3901. EXTERN_API_C( OSStatus )
  3902. OTLoadCFMLibrary                (const char *            libName,
  3903.                                  UInt32 *                connID,
  3904.                                  UInt32                 loadFlags);
  3905.  
  3906. /* Load a CFM library and get a named pointer from it*/
  3907. EXTERN_API_C( void *)
  3908. OTGetCFMPointer                    (const char *            libName,
  3909.                                  const char *            entryName,
  3910.                                  UInt32 *                connID,
  3911.                                  UInt32                 loadFlags);
  3912.  
  3913. /* Get a named pointer from a CFM library that's already loaded*/
  3914. EXTERN_API_C( void *)
  3915. OTGetCFMSymbol                    (const char *            entryName,
  3916.                                  UInt32                 connID,
  3917.                                  UInt32                 loadFlags);
  3918.  
  3919. /* Release a connection to a CFM library*/
  3920. EXTERN_API_C( void )
  3921. OTReleaseCFMConnection            (UInt32 *                connID);
  3922.  
  3923. #if !TARGET_CPU_68K
  3924. /*
  3925.    You can call these routines in your CFM initialisation and termination
  3926.    routines to hold or unhold your libraries sections.
  3927. */
  3928. /*
  3929.    Used in a CFM InitProc, will hold the executable code, if applicable.
  3930.    This can also be the InitProc of the library
  3931. */
  3932. EXTERN_API_C( OSStatus )
  3933. OTHoldThisCFMLibrary            (const CFragInitBlock *    initBlock);
  3934.  
  3935. /*
  3936.    Used in a CFM terminate proc, will unhold the executable code, if applicable.
  3937.    This can also be the terminate proc of the library
  3938. */
  3939. EXTERN_API_C( void )
  3940. OTUnholdThisCFMLibrary            (void);
  3941.  
  3942. #endif  /* !TARGET_CPU_68K */
  3943.  
  3944. /* ASLM Utilities*/
  3945. /* Load an ASLM library*/
  3946. EXTERN_API_C( OSStatus )
  3947. OTLoadASLMLibrary                (const char *            libName);
  3948.  
  3949. /* Unload an ASLM library*/
  3950. EXTERN_API_C( void )
  3951. OTUnloadASLMLibrary                (const char *            libName);
  3952.  
  3953. /*
  3954.    This is an ASLM utility routine.  You can get it by including
  3955.    "LibraryManagerUtilities.h", but since we only use a few ASLM utilities,
  3956.    we put the prototype here for convenience.
  3957. */
  3958.  
  3959. EXTERN_API_C( void )
  3960. UnloadUnusedLibraries            (void);
  3961.  
  3962.  
  3963. #if !OTKERNEL
  3964. /*******************************************************************************
  3965. ** A few C++ objects for C++ fans
  3966. ********************************************************************************/
  3967. #if CALL_NOT_IN_CARBON
  3968.  
  3969. #ifdef __cplusplus
  3970. }                    // Terminate C definitions
  3971.  
  3972.     class OTConfiguration
  3973.     {
  3974.         public:
  3975.                     OTConfigurationRef    Clone()
  3976.                                         { return OTCfigCloneConfiguration(this); }
  3977.                 //
  3978.                 // The Path for PushChild and PushParent must be a single module
  3979.                 //
  3980.                     OTConfigurationRef    PushChild(const char* path, OSStatus* errPtr)
  3981.                                         { return OTCfigPushNewSingleChild(this, path, errPtr); }
  3982.                     OTConfigurationRef    PushParent(const char* path, OSStatus* errPtr)
  3983.                                         { return OTCfigPushParent(this, path, errPtr); }
  3984.                     OTConfigurationRef    PushNthChild(OTItemCount index, const char* path,
  3985.                                                      OSStatus* errPtr)
  3986.                                         { return OTCfigPushChild(this, index, path, errPtr); }
  3987.                     OSStatus            PopChild(OTItemCount index)
  3988.                                         { return OTCfigPopChild(this, index); }
  3989.  
  3990.                     OTConfigurationRef    GetChild(OTItemCount index = 0)
  3991.                                         { return OTCfigGetChild(this, index); }
  3992.                     OTConfigurationRef    GetParent()
  3993.                                         { return OTCfigGetParent(this); }
  3994.             
  3995.                     OSStatus            AddChild(OTConfigurationRef child)
  3996.                                         { return OTCfigAddChild(this, child); }
  3997.                     
  3998.                     OTConfigurationRef    NewChild(const char* path, OSStatus* errPtr)
  3999.                                         { return OTCfigNewChild(this, path, errPtr); }
  4000.         
  4001.                     OSStatus            SetPath(const char* path)
  4002.                                         { return OTCfigSetPath(this, path); }
  4003.             
  4004.                     Boolean                HasOptions()
  4005.                                         { return OTCfigGetOptionNetbuf(this)->len != 0; }
  4006.     };
  4007.  
  4008. /*    -------------------------------------------------------------------------
  4009.     Class TOTConfigurator
  4010.  
  4011.     This class is subclassed to do configuration for a protocol or protocol stack.
  4012.     Of course, you can also use OTNewConfigurator to do it from C.
  4013.     
  4014.     If you subclass it using C++, you MUST have a UInt32 field as the first
  4015.     field of your object that you do not touch or use.
  4016.     ------------------------------------------------------------------------- */
  4017.  
  4018. #if TARGET_CPU_68K && !defined(__SC__) && !defined(THINK_CPLUS)
  4019.     class TOTConfigurator : public SingleObject
  4020. #else
  4021.     class TOTConfigurator
  4022. #endif
  4023.     {
  4024.     #if defined(__SC__) || defined(THINK_CPLUS) || defined(__MRC__)
  4025.         private:
  4026.             virtual        void DummyVirtualFunction();
  4027.     #endif
  4028.                 
  4029.         public:
  4030.                 void*            operator new(OTByteCount size)
  4031.                                 { return OTAllocSharedClientMem(size); }
  4032.                 void            operator delete(void* mem)
  4033.                                 { OTFreeSharedClientMem(mem); };
  4034.                                 
  4035.                                 _MDECL TOTConfigurator();
  4036.             virtual                ~ _MDECL TOTConfigurator();
  4037.     
  4038.             virtual void        _MDECL HandleSystemEvent(OTEventCode event, OTResult result,
  4039.                                                          void* cookie)                        = 0;
  4040.             
  4041.             virtual OSStatus    _MDECL Configure(OTConfigurationRef)                            = 0;
  4042.             virtual OSStatus    _MDECL CreateStream(OTConfigurationRef, OTOpenFlags,
  4043.                                                      OTNotifyUPP, void* contextPtr)        = 0;
  4044.     };
  4045.  
  4046. extern "C" {        // resume C definitions
  4047. #endif /*__cplusplus*/
  4048.  
  4049. #endif /* CALL_NOT_IN_CARBON */
  4050. #endif  /* !OTKERNEL */
  4051.  
  4052. #endif  /* CALL_NOT_IN_CARBON */
  4053.  
  4054. #if defined(__MWERKS__) && TARGET_CPU_68K
  4055.     #pragma pop
  4056. #endif
  4057.  
  4058.  
  4059. #if PRAGMA_STRUCT_ALIGN
  4060.     #pragma options align=reset
  4061. #elif PRAGMA_STRUCT_PACKPUSH
  4062.     #pragma pack(pop)
  4063. #elif PRAGMA_STRUCT_PACK
  4064.     #pragma pack()
  4065. #endif
  4066.  
  4067. #ifdef PRAGMA_IMPORT_OFF
  4068. #pragma import off
  4069. #elif PRAGMA_IMPORT
  4070. #pragma import reset
  4071. #endif
  4072.  
  4073. #ifdef __cplusplus
  4074. }
  4075. #endif
  4076.  
  4077. #endif /* __OPENTRANSPORTPROTOCOL__ */
  4078.  
  4079.